Vary symbology by rotation using ArcPy

12-10-2022 07:13 PM
Status: Under Consideration
Labels (1)
Frequent Contributor


When creating feature layers using ArcPy:

There doesn’t seem to be a way to Vary symbology by rotation using ArcPy.

Could that functionality be added?

Related: ArcPy script to convert layer to individual feature layers for each symbology class

Tags (2)

Symbol—ArcGIS Pro | Documentation

(Read and Write)
Gets and sets the rotation value of a point symbol.



The question is a bit unclear.

Yes, there is symbol.angle, but that sets the angle value of each symbol.

What @Bud means is that there is no way in arcpy to Vary symbology by rotation—ArcGIS Pro | Documentation


Status changed to: Under Consideration

This is something we can consider but it will be a long time before we can provide this level of detail via the curated API. In the meantime, the CIM may be an option.  Before reviewing the code below it may be worth reviewing the Python CIM Access help topic:

I started with:


As suggested in the topic above, I created a before and after layer, saved them to LYRX files and compared the JSON differences.


Here is the code based on what I see above.  The before layer didn't have visual variable applied so I had to create the appropriate CIM objects, set the values to match above and then apply the newly created visual variable to the empty visual variable list associated with the layer.

p ='current')
m = p.listMaps('Map')[0]
l = m.listLayers('*BEFORE')[0]
maxLabel = 360 #this could be automated

#Create a rotation visual variable via the CIM
l_cim = l.getDefinition('V3')
visVar = arcpy.cim.CreateCIMObjectFromClassName('CIMRotationVisualVariable', 'V3')
visVar.visualVariableInfoX.randomMax = maxLabel
visVar.visualVariableInfoX.visualVariableInfoType = "None"
visVar.visualVariableInfoY.randomMax = maxLabel
visVar.visualVariableInfoY.visualVariableInfoType = "None"
visVar.visualVariableInfoZ.randomMax = maxLabel
visVar.visualVariableInfoZ.visualVariableInfoType = "Expression"
#Create expression for Xinfo
expInf = arcpy.cim.CreateCIMObjectFromClassName('CIMExpressionInfo', 'V3')
expInf.title = "Custom"
expInf.expression = "$feature.Rotation"  #field called rotation
expInf.returnType = "Default"

visVar.visualVariableInfoZ.valueExpressionInfo = expInf
visVar.rotationTypeZ = "Arithmetic"

l_cim.renderer.visualVariables.append(visVar) #Apply visual variable
l.setDefinition(l_cim) #set back to layer


And the final result:


I hope this helps,

Jeff - Layout and teams


Thanks Jeff, that helps alot.

I have done some work with the CIM (especially configuring popups), but I haven't looked too far into it regarding symbology.