<?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: Retain Layer Definition Queries with Layout in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204585#M58877</link>
    <description>&lt;P&gt;Because the pasted code does NOT show indentation, which is critical for Python code blocks, here is a screen shot of the same code above.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49015i8847D17BB32D3C59/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Fri, 19 Aug 2022 16:03:35 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2022-08-19T16:03:35Z</dc:date>
    <item>
      <title>Retain Layer Definition Queries with Layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204271#M58830</link>
      <description>&lt;P&gt;Is it possible to retain definition query settings for layers on a map based on the layout?&lt;/P&gt;&lt;P&gt;I have a series of layouts that reference a single map that require changing the pre-defined definition query for several layers in order to match the content on the map to the desired layout mapframe extent.&lt;/P&gt;&lt;P&gt;The intended result can be achieved by making copies of the map itself and defining the definition queries for the layers uniquely for each copy, but then that means any change that might need to be made to the contents of the map would need to be done for each individual copy of the map.&lt;/P&gt;&lt;P&gt;I have specific layers on the map set up with 47 pre-defined definition queries that match up with a specific layout, so Layout 1 requires that Definition Query 1 be set for the specific layers on the map, then for Layout 2, the layers have to use Definition Query 2, etc.&amp;nbsp; However, because the definition query settings are only controlled by the map, I have to manually go through each layer and set them to use the correct definition query for the layout I am currently working with each time that I want to export to PDF.&lt;/P&gt;&lt;P&gt;A way to have the layouts retain the filtering settings configured on the map while working in each individual Layout would be amazing.&lt;/P&gt;&lt;P&gt;I do not know if this is something that is possible or can be achieved with some scripting when trying to export each Layout to PDF?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 18:37:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204271#M58830</guid>
      <dc:creator>JMitchell</dc:creator>
      <dc:date>2022-08-18T18:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Layer Definition Queries with Layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204582#M58876</link>
      <description>&lt;P&gt;Hello JMitchell,&lt;/P&gt;&lt;P&gt;Have you considered using Python Map Automation?&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/introduction-to-arcpy-mp.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/introduction-to-arcpy-mp.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It is an API that allows you to automate the contents of projects such as maps, layers, layouts and much more.&lt;/P&gt;&lt;P&gt;The devil is in the detail but here is a very generic script that exports a PDF for each unique set of DefQueries. The code obviously needs to be modified to work with your project/data and depending on your specific needs, more logic most likely needs to be added.&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Jeff - Layout and arcpy.mp teams&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;p = arcpy.mp.ArcGISProject('current')&lt;BR /&gt;lyt = p.listLayouts('Yosemite National Park')[0]&lt;/P&gt;&lt;P&gt;#Build a list of definition queries&lt;BR /&gt;defQuery1 = "NAME = 'Arch Rock Entrance'"&lt;BR /&gt;defQuery2 = "NAME = 'Big Oak Flat Entrance'"&lt;BR /&gt;defQuery3 = "NAME = 'Hetch Hetchy Entrance'"&lt;BR /&gt;defQueryList = [defQuery1, defQuery2, defQuery3]&lt;/P&gt;&lt;P&gt;#Iterate through all the def queries for all the maps&lt;BR /&gt;#and update layer def queries IF one is present&lt;/P&gt;&lt;P&gt;for dq in defQueryList:&lt;BR /&gt;for m in p.listMaps():&lt;BR /&gt;for lyr in m.listLayers():&lt;BR /&gt;if lyr.supports("DEFINITIONQUERY"):&lt;BR /&gt;if lyr.definitionQuery != None:&lt;BR /&gt;lyr.definitionQuery = dq&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#build unique outout name based on the defquery string&lt;BR /&gt;start = "NAME = '"&lt;BR /&gt;end = " Entrance'"&lt;BR /&gt;lytNamePath = "C:\\Temp\\" + (dq.split(start))[1].split(end)[0] + ".pdf"&lt;/P&gt;&lt;P&gt;#export to PDF before using the next def query&lt;BR /&gt;lyt.exportToPDF(lytNamePath)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 19 Aug 2022 16:00:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204582#M58876</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2022-08-19T16:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Layer Definition Queries with Layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204585#M58877</link>
      <description>&lt;P&gt;Because the pasted code does NOT show indentation, which is critical for Python code blocks, here is a screen shot of the same code above.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49015i8847D17BB32D3C59/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 16:03:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204585#M58877</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2022-08-19T16:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Layer Definition Queries with Layout</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204588#M58878</link>
      <description>&lt;P&gt;Hi Jeff,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate the suggestion and sample!&amp;nbsp; I will work with this and see what I can do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 16:07:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/retain-layer-definition-queries-with-layout/m-p/1204588#M58878</guid>
      <dc:creator>JMitchell</dc:creator>
      <dc:date>2022-08-19T16:07:53Z</dc:date>
    </item>
  </channel>
</rss>

