<?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: Change Definition Query of Multiple Layers with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-definition-query-of-multiple-layers-with/m-p/414769#M32668</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
queryStr = "Hello World"
mxd = arcpy.mapping.MapDocument("CURRENT")

for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp; if lyr.supports("DEFINITIONQUERY"): 
&amp;nbsp; lyr.definitionQuery = queryStr

del mxd
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 18:48:19 GMT</pubDate>
    <dc:creator>DanielJohns</dc:creator>
    <dc:date>2021-12-11T18:48:19Z</dc:date>
    <item>
      <title>Change Definition Query of Multiple Layers with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-definition-query-of-multiple-layers-with/m-p/414767#M32666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can anyone help me with a python script that will change the definition query of two layers to the same thing. I have 2 layers that I want to change the definition query on at the same time to the same value(s).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ex) Layer1 Definition Query ---[pid] = 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer2 Definition Query ---[pid] = 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to be able to update both definition queries in one step using python.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 17:42:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-definition-query-of-multiple-layers-with/m-p/414767#M32666</guid>
      <dc:creator>CraigLimbert</dc:creator>
      <dc:date>2010-12-15T17:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Change Definition Query of Multiple Layers with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-definition-query-of-multiple-layers-with/m-p/414768#M32667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well you would create two layer objects with arcpy.mapping and then iterate over them changing the definition queries using the definitionQuery attribute of the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Create_Layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for layer in layers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.definitionQuery='[pid] = 4'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Layer/00s300000008000000/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Dec 2010 17:48:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-definition-query-of-multiple-layers-with/m-p/414768#M32667</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2010-12-15T17:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Change Definition Query of Multiple Layers with Python</title>
      <link>https://community.esri.com/t5/python-questions/change-definition-query-of-multiple-layers-with/m-p/414769#M32668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
queryStr = "Hello World"
mxd = arcpy.mapping.MapDocument("CURRENT")

for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp; if lyr.supports("DEFINITIONQUERY"): 
&amp;nbsp; lyr.definitionQuery = queryStr

del mxd
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:48:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-definition-query-of-multiple-layers-with/m-p/414769#M32668</guid>
      <dc:creator>DanielJohns</dc:creator>
      <dc:date>2021-12-11T18:48:19Z</dc:date>
    </item>
  </channel>
</rss>

