AnsweredAssumed Answered

Adding feature class and applying symbology in ArcGIS Pro using arcpy

Question asked by sean.hough_qgsp on Jun 13, 2018
Latest reply on Jun 18, 2018 by Dan_Patterson

Using an arcpy script run from a toolbox, I want to import a feature class from a geodatabase into an ArcPro map and then symbolise that layer based on a lyrx file stored on disk. Here is a simplified version:

 

import arcpy, os 
aprx
= arcpy.mp.ArcGISProject('CURRENT')
m = aprx.listMaps('*')[0]
outputWorkspace = r"C:\Path\To\MyProject.gdb"
arcpy.env.workspace = outputWorkspace
out_fc
= "fc_data"
out_fc_p = os.path.join(outputWorkspace, out_fc)
ref_lyrx = r"C:\Path\To\symbol_ref.lyrx"
m.addDataFromPath(out_fc_p)
out_fc_lyr = m.listLayers()[0]
arcpy.ApplySymbologyFromLayer_management(out_fc_lyr, ref_lyrx)

The script completes without error but no visible change is made to the symbology. Is this a bug? I've reviewed many similar questions but have been unable to resolve this.

Outcomes