<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcGIS Pro 3.x CIM Changes vs ArcGIS Pro 2.x in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-pro-3-x-cim-changes-vs-arcgis-pro-2-x/m-p/1304801#M68192</link>
    <description>&lt;P&gt;Hi there,&lt;BR /&gt;I have an old 2.9.x code version script: below that used to reference the 'grids' element within the CIMGraphicElement Family,&lt;BR /&gt;&lt;BR /&gt;However I have come to discover this variable may no longer exist in ArcGIS Pro 3?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As the is no option to directly change the grid reference of a layout from arcpy you must do it with the CIM.&lt;/P&gt;&lt;P&gt;The Code Snippet is below imports a layout into a pro session and does it maths calculations prior to this stage&lt;BR /&gt;&lt;BR /&gt;However with the version change, Im a bit stumped as to what to fix in order to get this working,&lt;/P&gt;&lt;P&gt;# Import the Layout into the current project and update it&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;aprx.importDocument(pagx_in)&lt;BR /&gt;layout = aprx.listLayouts(out_Template)[0]&lt;BR /&gt;arcpy.AddMessage("Imported template:" + layout.name)&lt;/P&gt;&lt;P&gt;mf = layout.listElements('MAPFRAME_ELEMENT','Main')[0]# Return the main map frame element. This needs to be named 'Main' in the template/pagx&lt;BR /&gt;m = mf.map # the map view referenced by the user chosen layout (FFT Main).&lt;BR /&gt;extent = mf.camera.getExtent() #get dataframe extent. This will be in whatever coordinate system the&lt;BR /&gt;arcpy.AddMessage("Got extent: " + str(extent))&lt;/P&gt;&lt;P&gt;mf.map.spatialReference = sr&lt;BR /&gt;mf.spatialReference = sr&lt;BR /&gt;proj = "UTM " + UTM_zone + UTM_letter&lt;BR /&gt;gps = "UTM UPS"&lt;BR /&gt;datum = "WGS84"&lt;BR /&gt;arcpy.AddMessage("Dataframe set to: " + mf.spatialReference.name)&lt;/P&gt;&lt;P&gt;# Update the UTM MGRS Grid. This is done through updating the CIM Definition as no arcpy method exists.&lt;BR /&gt;&lt;BR /&gt;layout_CIM = layout.getDefinition("V3")# Get the CIM Definition of the layout&lt;BR /&gt;mf_CIM = layout_CIM.elements[0]&lt;/P&gt;&lt;P&gt;mf_CIM.grids[0].projectedCoordinateSystem.get("wkid") #Get the coordinate system of the UTM MGRS grid&lt;BR /&gt;mf_CIM.grids[0].projectedCoordinateSystem['wkid'] = srNum # set to updated coordinate system&lt;BR /&gt;mf_CIM.grids[0].projectedCoordinateSystem['latestWkid'] = srNum # set to updated coordinate system&lt;BR /&gt;layout.setDefinition(layout_CIM) #set the updated CIM definition&lt;BR /&gt;&lt;BR /&gt;I keep getting:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;line 1538, in &amp;lt;module&amp;gt;
    wkid = mf_CIM.grids[0].projectedCoordinateSystem.get("wkid")
AttributeError: 'CIMGraphicElement' object has no attribute 'grids'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is anyone able to provide some advice on migrating this to work with the ArcGIS Pro 3 CIM environment?&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jun 2023 10:26:26 GMT</pubDate>
    <dc:creator>GeoNZ</dc:creator>
    <dc:date>2023-06-30T10:26:26Z</dc:date>
    <item>
      <title>ArcGIS Pro 3.x CIM Changes vs ArcGIS Pro 2.x</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-pro-3-x-cim-changes-vs-arcgis-pro-2-x/m-p/1304801#M68192</link>
      <description>&lt;P&gt;Hi there,&lt;BR /&gt;I have an old 2.9.x code version script: below that used to reference the 'grids' element within the CIMGraphicElement Family,&lt;BR /&gt;&lt;BR /&gt;However I have come to discover this variable may no longer exist in ArcGIS Pro 3?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As the is no option to directly change the grid reference of a layout from arcpy you must do it with the CIM.&lt;/P&gt;&lt;P&gt;The Code Snippet is below imports a layout into a pro session and does it maths calculations prior to this stage&lt;BR /&gt;&lt;BR /&gt;However with the version change, Im a bit stumped as to what to fix in order to get this working,&lt;/P&gt;&lt;P&gt;# Import the Layout into the current project and update it&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;aprx.importDocument(pagx_in)&lt;BR /&gt;layout = aprx.listLayouts(out_Template)[0]&lt;BR /&gt;arcpy.AddMessage("Imported template:" + layout.name)&lt;/P&gt;&lt;P&gt;mf = layout.listElements('MAPFRAME_ELEMENT','Main')[0]# Return the main map frame element. This needs to be named 'Main' in the template/pagx&lt;BR /&gt;m = mf.map # the map view referenced by the user chosen layout (FFT Main).&lt;BR /&gt;extent = mf.camera.getExtent() #get dataframe extent. This will be in whatever coordinate system the&lt;BR /&gt;arcpy.AddMessage("Got extent: " + str(extent))&lt;/P&gt;&lt;P&gt;mf.map.spatialReference = sr&lt;BR /&gt;mf.spatialReference = sr&lt;BR /&gt;proj = "UTM " + UTM_zone + UTM_letter&lt;BR /&gt;gps = "UTM UPS"&lt;BR /&gt;datum = "WGS84"&lt;BR /&gt;arcpy.AddMessage("Dataframe set to: " + mf.spatialReference.name)&lt;/P&gt;&lt;P&gt;# Update the UTM MGRS Grid. This is done through updating the CIM Definition as no arcpy method exists.&lt;BR /&gt;&lt;BR /&gt;layout_CIM = layout.getDefinition("V3")# Get the CIM Definition of the layout&lt;BR /&gt;mf_CIM = layout_CIM.elements[0]&lt;/P&gt;&lt;P&gt;mf_CIM.grids[0].projectedCoordinateSystem.get("wkid") #Get the coordinate system of the UTM MGRS grid&lt;BR /&gt;mf_CIM.grids[0].projectedCoordinateSystem['wkid'] = srNum # set to updated coordinate system&lt;BR /&gt;mf_CIM.grids[0].projectedCoordinateSystem['latestWkid'] = srNum # set to updated coordinate system&lt;BR /&gt;layout.setDefinition(layout_CIM) #set the updated CIM definition&lt;BR /&gt;&lt;BR /&gt;I keep getting:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;line 1538, in &amp;lt;module&amp;gt;
    wkid = mf_CIM.grids[0].projectedCoordinateSystem.get("wkid")
AttributeError: 'CIMGraphicElement' object has no attribute 'grids'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is anyone able to provide some advice on migrating this to work with the ArcGIS Pro 3 CIM environment?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jun 2023 10:26:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-pro-3-x-cim-changes-vs-arcgis-pro-2-x/m-p/1304801#M68192</guid>
      <dc:creator>GeoNZ</dc:creator>
      <dc:date>2023-06-30T10:26:26Z</dc:date>
    </item>
  </channel>
</rss>

