Select to view content in your preferred language

No symbology for layer object

1338
4
02-03-2017 02:14 AM
Marliesde_Keizer
Deactivated User

I am trying to update the symbology of a layer using arcpy, but I get an error saying:

'Layer' object has no attribute 'symbology'

My (stripped) code is:

mySettings = GetSettings() #returns a pandas dataframe object
myProject = arcpy.mp.ArcGISProject(mySettings.loc["ArcGIS project"]["Value"])
myMap = myProject.listMaps("Layers")[0]
myTemplate = arcpy.mp.LayerFile(mySettings.loc["Template file"]["Value"]).listLayers()[0]
myMap.addLayer(myTemplate)
mySymbology = myTemplate.symbology

Can anyone tell me what is wrong with this code?

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

symbology is readonly Layer—Help | ArcGIS Desktop 

it can be set in arcmap Layer—Help | ArcGIS Desktop 

in PRO Layer—ArcPy | ArcGIS Desktop symbology is read and write...

the symbology gives code examples Symbology—ArcPy | ArcGIS Desktop 

0 Kudos
Marliesde_Keizer
Deactivated User

I'm sorry, I can't figure out what you mean by this answer. Symbology is read and write in Pro? But why can't I access it then?

0 Kudos
DanPatterson_Retired
MVP Emeritus

No clue... I am just the messenger.  Did you check the code example at the bottom of the last link or did you stop part way through?

0 Kudos
Marliesde_Keizer
Deactivated User

It turns out I had the wrong version of ArcGIS Pro installed. With updating everything is fixed. Thanx for the feedback.

0 Kudos