<?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 Re: Layouts - trying to add a Grid via Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/layouts-trying-to-add-a-grid-via-python/m-p/1328306#M68628</link>
    <description>&lt;P&gt;Try using CIM? It's a pain, but it looks like there should be an option in here. At the very least, you're able to edit the grid once it exists, so I assume you can turn it on.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/cim-spec/blob/809fb365d8d204d1fbdc51b3fab5bd17d88de2d1/docs/v2/CIMLayout.md#cimmapframe-1" target="_blank" rel="noopener"&gt;Map Frame CIM Element&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, as all things CIM, it's a GIANT pain in the rear. I'd advise copying an existing grid to use as a base, if you can. Then remember, you're setting the layout's definition at the end. See the final example on this page&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm#:~:text=The%20following%20code%20will%20ultimately%20create%20a%20polygon%20CIMGraphicElement%20on%20a%20layout.%20It%20uses%20the%20CreateCIMObjectFromClassName%20multiple%20times%20for%20all%20the%20dependent%20CIM%20classes%20needed%20to%20construct%20a%20polygon%20graphic%20element." target="_blank" rel="noopener"&gt;Python CIM Access&lt;/A&gt;&amp;nbsp;to get you started.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/cim-spec/blob/809fb365d8d204d1fbdc51b3fab5bd17d88de2d1/docs/v2/CIMLayout.md" target="_blank"&gt;cim-spec/docs/v2/CIMLayout.md at 809fb365d8d204d1fbdc51b3fab5bd17d88de2d1 · Esri/cim-spec · GitHub&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2023 15:21:40 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2023-09-13T15:21:40Z</dc:date>
    <item>
      <title>Layouts - trying to add a Grid via Python</title>
      <link>https://community.esri.com/t5/python-questions/layouts-trying-to-add-a-grid-via-python/m-p/1326232#M68540</link>
      <description>&lt;P&gt;I'm working with Python to load a web map into a map frame on a layout. However, what I'd now like to do is add a Grid (or Graticule, or Ticks) so that we can see coordinates - preferably along the top and left sides, with the lines either being not visible or transparent.&lt;/P&gt;&lt;P&gt;Currently I'm using the below code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#create an aprx using a webmap json and a layout template, and a map based on it
result = arcpy.mp.ConvertWebMapToArcGISProject(data, templateFull)
aprx = result.ArcGISProject
m = aprx.listMaps()[0]
#find our layout and the map frame within
lyt = aprx.listLayouts()[0]
mf = lyt.listElements("mapframe_element", "WEBMAP_MAP_FRAME")[0]
#assign the map to our map frame
mf.map = m
#just gets some extents and sets the map frame and map camera
myExtent = arcpy.Extent(pointMin.centroid.X, pointMax.centroid.Y, pointMax.centroid.X, pointMin.centroid.Y)
mf.camera.setExtent(myExtent)
mf.camera.scale = mf.camera.scale * 1.1
m.defaultCamera = mf.camera&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Just about everything I can find so far indicates that, if you want to do it programatically, you have to create a Grid "layer" - basically a layer of square polygons, but I'm sure you must be able to expose the Map Frame's Grid settings. You can add a Grid in the Layout editor but, as this is generated on-the-fly as it were from a web map, that option is greyed out.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2023 06:20:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layouts-trying-to-add-a-grid-via-python/m-p/1326232#M68540</guid>
      <dc:creator>MichaelBell</dc:creator>
      <dc:date>2023-09-07T06:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Layouts - trying to add a Grid via Python</title>
      <link>https://community.esri.com/t5/python-questions/layouts-trying-to-add-a-grid-via-python/m-p/1328306#M68628</link>
      <description>&lt;P&gt;Try using CIM? It's a pain, but it looks like there should be an option in here. At the very least, you're able to edit the grid once it exists, so I assume you can turn it on.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/cim-spec/blob/809fb365d8d204d1fbdc51b3fab5bd17d88de2d1/docs/v2/CIMLayout.md#cimmapframe-1" target="_blank" rel="noopener"&gt;Map Frame CIM Element&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, as all things CIM, it's a GIANT pain in the rear. I'd advise copying an existing grid to use as a base, if you can. Then remember, you're setting the layout's definition at the end. See the final example on this page&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm#:~:text=The%20following%20code%20will%20ultimately%20create%20a%20polygon%20CIMGraphicElement%20on%20a%20layout.%20It%20uses%20the%20CreateCIMObjectFromClassName%20multiple%20times%20for%20all%20the%20dependent%20CIM%20classes%20needed%20to%20construct%20a%20polygon%20graphic%20element." target="_blank" rel="noopener"&gt;Python CIM Access&lt;/A&gt;&amp;nbsp;to get you started.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/cim-spec/blob/809fb365d8d204d1fbdc51b3fab5bd17d88de2d1/docs/v2/CIMLayout.md" target="_blank"&gt;cim-spec/docs/v2/CIMLayout.md at 809fb365d8d204d1fbdc51b3fab5bd17d88de2d1 · Esri/cim-spec · GitHub&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 15:21:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/layouts-trying-to-add-a-grid-via-python/m-p/1328306#M68628</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-09-13T15:21:40Z</dc:date>
    </item>
  </channel>
</rss>

