Select to view content in your preferred language

ArcGIS Pro 3.x CIM Changes vs ArcGIS Pro 2.x

06-30-2023 03:26 AM
Labels (3)
Occasional Contributor

Hi there,
I have an old 2.9.x code version script: below that used to reference the 'grids' element within the CIMGraphicElement Family,

However I have come to discover this variable may no longer exist in ArcGIS Pro 3?

As the is no option to directly change the grid reference of a layout from arcpy you must do it with the CIM.

The Code Snippet is below imports a layout into a pro session and does it maths calculations prior to this stage

However with the version change, Im a bit stumped as to what to fix in order to get this working,

# Import the Layout into the current project and update it
aprx ="CURRENT")
layout = aprx.listLayouts(out_Template)[0]
arcpy.AddMessage("Imported template:" +

mf = layout.listElements('MAPFRAME_ELEMENT','Main')[0]# Return the main map frame element. This needs to be named 'Main' in the template/pagx
m = # the map view referenced by the user chosen layout (FFT Main).
extent = #get dataframe extent. This will be in whatever coordinate system the
arcpy.AddMessage("Got extent: " + str(extent)) = sr
mf.spatialReference = sr
proj = "UTM " + UTM_zone + UTM_letter
gps = "UTM UPS"
datum = "WGS84"
arcpy.AddMessage("Dataframe set to: " +

# Update the UTM MGRS Grid. This is done through updating the CIM Definition as no arcpy method exists.

layout_CIM = layout.getDefinition("V3")# Get the CIM Definition of the layout
mf_CIM = layout_CIM.elements[0]

mf_CIM.grids[0].projectedCoordinateSystem.get("wkid") #Get the coordinate system of the UTM MGRS grid
mf_CIM.grids[0].projectedCoordinateSystem['wkid'] = srNum # set to updated coordinate system
mf_CIM.grids[0].projectedCoordinateSystem['latestWkid'] = srNum # set to updated coordinate system
layout.setDefinition(layout_CIM) #set the updated CIM definition

I keep getting:

line 1538, in <module>
    wkid = mf_CIM.grids[0].projectedCoordinateSystem.get("wkid")
AttributeError: 'CIMGraphicElement' object has no attribute 'grids'

 Is anyone able to provide some advice on migrating this to work with the ArcGIS Pro 3 CIM environment?

0 Kudos
0 Replies