<?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: Dynamically set the DPP &amp;quot;Page Definition&amp;quot; query based on a changing variable in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/dynamically-set-the-dpp-amp-quot-page-definition/m-p/524206#M5670</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Page Definition Queries are only available in the UI if you are using DDP but that is not to say you can't accomplish the same thing outside of the UI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With arcpy.mapping you would simply set a .definitionQuery on each appropriate layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, let us say I add two State layers to a dataframe/map.&amp;nbsp; The bottom layer is the index layer and the top layer is a masking layer.&amp;nbsp; I'm using the masking layer to mask away anything outside the current index feature.&amp;nbsp; I set the top layer to be solid white.&amp;nbsp; In the UI, I would set the Page Definition Query to Not Match the index field state name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In arcpy, I would use code similar to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") maskLyr = arcpy.mapping.ListLayers(mxd, "Masking Layer")[0]&amp;nbsp; #Layer to apply def query. for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): &amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum &amp;nbsp;&amp;nbsp;&amp;nbsp; stateName = mxd.dataDrivenPages.pageRow.STATE_NAME&amp;nbsp; #Get field used in dynamic query &amp;nbsp;&amp;nbsp;&amp;nbsp; maskLyr.definitionQuery = "\"STATE_NAME\" &amp;lt;&amp;gt; '" + stateName + "'"&amp;nbsp; #apply dynamic query &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r"C:\Temp\\" + stateName + ".pdf") del mxd&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Sep 2012 15:06:57 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2012-09-20T15:06:57Z</dc:date>
    <item>
      <title>Dynamically set the DPP &amp;quot;Page Definition&amp;quot; query based on a changing variable</title>
      <link>https://community.esri.com/t5/mapping-questions/dynamically-set-the-dpp-amp-quot-page-definition/m-p/524205#M5669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have the need to dynamically set a layer's "Page Definition" query of multiple layers based on a ModelBuilder variable retrieved from a field using an iterator. Each value in the field thus must lead to it's own query and has to be set as the Page Definition of an exported layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, looking around in the ArcToolbox, and the arcPy layer properties, it seems the "Page Definition" isn't actually being exposed anywhere except through the user operated dialogs of ArcGIS itself??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I may well be overlooking something, but are there really no options to programmatically set the DPP "Page Definition" through python scripting that can be integrated with a ModelBuilder model?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Marco&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Sep 2012 19:57:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/dynamically-set-the-dpp-amp-quot-page-definition/m-p/524205#M5669</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2012-09-19T19:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically set the DPP "Page Definition" query based on a changing variable</title>
      <link>https://community.esri.com/t5/mapping-questions/dynamically-set-the-dpp-amp-quot-page-definition/m-p/524206#M5670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Page Definition Queries are only available in the UI if you are using DDP but that is not to say you can't accomplish the same thing outside of the UI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With arcpy.mapping you would simply set a .definitionQuery on each appropriate layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, let us say I add two State layers to a dataframe/map.&amp;nbsp; The bottom layer is the index layer and the top layer is a masking layer.&amp;nbsp; I'm using the masking layer to mask away anything outside the current index feature.&amp;nbsp; I set the top layer to be solid white.&amp;nbsp; In the UI, I would set the Page Definition Query to Not Match the index field state name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In arcpy, I would use code similar to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") maskLyr = arcpy.mapping.ListLayers(mxd, "Masking Layer")[0]&amp;nbsp; #Layer to apply def query. for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): &amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum &amp;nbsp;&amp;nbsp;&amp;nbsp; stateName = mxd.dataDrivenPages.pageRow.STATE_NAME&amp;nbsp; #Get field used in dynamic query &amp;nbsp;&amp;nbsp;&amp;nbsp; maskLyr.definitionQuery = "\"STATE_NAME\" &amp;lt;&amp;gt; '" + stateName + "'"&amp;nbsp; #apply dynamic query &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r"C:\Temp\\" + stateName + ".pdf") del mxd&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Sep 2012 15:06:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/dynamically-set-the-dpp-amp-quot-page-definition/m-p/524206#M5670</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-09-20T15:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically set the DPP "Page Definition" query based on a changing variable</title>
      <link>https://community.esri.com/t5/mapping-questions/dynamically-set-the-dpp-amp-quot-page-definition/m-p/524207#M5671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jeff,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my case, I finally decided to set the visibility of the layers on/off depending on data driven page index, as this did the job I wanted it to do for this particular case. It took some time to figure out how to implement this based on Python example scripts I found in the Help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still think it would be nice if more of the DDP stuff was exposed through the ArcToolbox and thus directly usuable in ModelBuilder. Quite a lot of people are still unfamiliar with Python, and learning a new programming language can be a long story, especially for those without any previous programming experience or simply difficulties to adjust to programming type tasks. I am not one of them, but I have seen other people struggling with any kind of programming style "logic". Connecting things up in a graphic style designer like ModelBuilder, is just more accessible for some.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Marco&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 12:11:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/dynamically-set-the-dpp-amp-quot-page-definition/m-p/524207#M5671</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2012-09-26T12:11:55Z</dc:date>
    </item>
  </channel>
</rss>

