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")
l = m.listLayers("xylayer")
sym = l.symbology
##begin code that doesn't work
##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?
You'll need to get down to the CIM level for the rotation piece.
For more detailed information please take a look at Python CIM access—ArcPy | Documentation as well as an excellent presentation from the Dev Summit https://www.youtube.com/watch?v=RkyzeOgCHe4&list=PLaPDDLTCmy4Ys8vfmC7DbX3FHSsyosvh7&index=28
Are you saying that even with listSymbolsFromGallery(<your_symbol>) you get back an empty list?
I just tried it with Pro 2.6 and it seems to work in my list test case.
and to complete Zachary's code
l.symbology = sym