I am struggling to change the text color of an Annotation class via arcpy.
For example, I have this in my ArcGIS Pro project:
A simple point which is annotated with the text "272.22".
The properties of this instance "272.22" of the Annotation class look as follows (some attribute values are German; "Platziert" means "placed", "Nein" means "no", "Unten" means "Bottom", "Links" means "left", so nothing wild):
If I look at the properties of the layer of the Annotation class in the content tree, the following properties are displayed (again some German attributes and attribute values, but I think the concrete values are not relevant for the problem and pretty self-explanatory as well):
How can I change the color of all the texts of this Annotation class via arcpy?
In my arcpy script, I already have a reference to the corresponding layer object (acquired via the listLayers() method of the active map). The Annotation's layer does not have a symbology, so I can't change the color via symbology.renderer.symbol.color. Is there a way for Annotations? I am executing my script in the ArcGIS Pro python window.
Solved! Go to Solution.
This code snippet makes all my annotation text blue 🙂
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps()[0]
l = m.listLayers()[0]
cim_l = l.getDefinition('V3')
cim_l.symbolSubstitutionType = 'Color'
cim_l.massColorSubstitute.values = [0, 0, 255, 100]
l.setDefinition(cim_l)
I hope this can get you started! CIM is fun!
Regards
Carsten
I'm not sure you can do this with the functionality exposed in arcpy.
I think I would try CIM. It's a bit finicky to use, but you have access to all the settings that you have in the dialogs. The challenge is to find which setting to change in the huge JSONS.
More info here: Python CIM access—ArcGIS Pro | Documentation
I think I have seen a demo where they changed label colors using CIM. Maybe plenary at Developer Summit 2019?
Regards
Carsten
It was this one I was thinking about: Map Automation - Esri Videos: GIS, Events, ArcGIS Products & Industries
Not exactly labels, but think you can do something similar.
This code snippet makes all my annotation text blue 🙂
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps()[0]
l = m.listLayers()[0]
cim_l = l.getDefinition('V3')
cim_l.symbolSubstitutionType = 'Color'
cim_l.massColorSubstitute.values = [0, 0, 255, 100]
l.setDefinition(cim_l)
I hope this can get you started! CIM is fun!
Regards
Carsten
Hi Carsten,
nice, thank you so much! 😀 This is already what I needed. Cheers!
(PS: Sorry for my late response, had some stress in some other projects and also was sick for a few days.)
No worries. I am happy that you could use it!