Agreed. If I could even read which anchor point the layout item was using, even if I couldn't change it, that would be tremendously helpful.
Hi,
Any update on this? did you find a solution? i'm facing the same issue
This would be very helpful, right now I have to validate the anchor point positions by hand which kind of defeats the purpose of automating with python
Completely agree with other commenters here, and here. This would make automation in Pro/Map tremendously easier. ESRI, can you please add an "elementAnchor" property to the different layout elements.
+1 for this idea
Starting with Pro 2.5, this can be accomplished using Python CIM Access
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm
Here is a simple snippet:
p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
lyt_cim = lyt.getDefinition('V3')
for e in lyt_cim.elements:
if e.name == 'Rectangle':
print(elm.anchor)
###BottomLeftCorner
Starting with Pro 2.5, this can be accomplished using Python CIM Access
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm
Here is a simple snippet:
p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
lyt_cim = lyt.getDefinition('V2') #for 2.x and '3.0' for 3x
for e in lyt_cim.elements:
if e.name == 'Rectangle':
print(elm.anchor)
###BottomLeftCorner
Cool! Thanks for the update.
I received an error saying I needed to use cim_version 'V2' but that seems to work okay.
Are you supposed to be able to set the anchor as well? It looks like it works, but the actual element properties in the layout don't seem to update.
Also, type, should be " print(e.anchor)"
For anyone in the future wondering how to set the anchor point, heres a code snipped from the resources provided by esri (ArcGIS Pro 2.5 CIM Samples V1 - Overview)
p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts('GreatLakes')[0]
lyt_cim = lyt.getDefinition("V2") #Get the layout's CIM definition
#Iterate though all layout elements to find the PointText element
for elm in lyt_cim.elements:
if elm.name == "Point Text":
txt = elm
elm.anchor = 'CenterPoint' #Change anchor position
lyt.setDefinition(lyt_cim) #Set the layout's CIM definition
The last line (12) is required for the anchor to change
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.