AnsweredAssumed Answered

Appy symbology does not work with arcpy

Question asked by Fengchao on Nov 9, 2018
Latest reply on Nov 12, 2018 by Fengchao

Hello I want to load multiple shape files to the table of content and add them to a group layer in ArcGIS Pro with arcpy. Then apply the defined symbology to all these layers. What I have wrote is as below:

aprx = arcpy.mp.ArcGISProject ("CURRENT")
aprxMap = aprx.listMaps("Map")[0]

FC5symbology = r"C:\Program Files (x86)\ArcGIS\Desktop10.5\Styles\Prep_layer_definition\retest_group_layers\ArcGIS_Pro_test\FC5_symbology.lyrx"

aprxMap.addDataFromPath("C:\users\Proexcersise\CodeTest\T18_IND_02_BANG_999\NAV\Clusters\FC5_1.shp")
aprxMap.addDataFromPath("C:\users\Proexcersise\CodeTest\T18_IND_02_BANG_999\NAV\Clusters\FC5_2.shp")

for lyr in aprxMap.listLayers():
    if "FC5" in lyr.name and not lyr.isGroupLayer:
       aprxMap.addLayerToGroup(FC5layer, lyr, "BOTTOM")
       arcpy.ApplySymbologyFromLayer_management(lyr,FC5symbology)

But then I got an error.

 

Anyone can help me with this error. Thanks!

Outcomes