AnsweredAssumed Answered

Assigning an icon from a .stylx file and rotating it, in arcpy

Question asked by Zachary.Klaas.tc on Sep 6, 2018

I want to use arcpy to apply a symbol from a .stylx file and then rotate the symbol according to a variable.

 

Doing this manually, this merely involves clicking on the icon from the gallery pane (where the symbol is located despite being in a .stylx file, the style is clearly regarded as a "project style") and then using "Vary symbology by attribute", "Rotation", selecting the rotation variable, and geographic style for the method of rotation.  It's easy manually, I just want my script to do it automatically.

 

The relevant code:

   aprx = arcpy.mp.ArcGISProject("CURRENT")
   m = aprx.listMaps("AIS Live Feed")[0]
   l = m.listLayers("xylayer")[0]
   sym = l.symbology

 

   ##begin code that doesn't work
   sym.renderer.symbol.applySymbolFromGallery("ShipAIS")
   ##end code that doesn't work

 

It doesn't regard my ShipAIS icon, stored in its .stylx file, as part of my gallery.  I am able to get the icon to change with this code if I select one that is in my default gallery.  Even doing that, though, I don't know how to direct arcpy to rotate an icon once I'm able to access it - there appears to be an "angle" attribute, but I'm not sure how to apply it.

 

Does anyone know how I might do this?

Outcomes