<?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: What should I change to run this python script on the specific layers only (not all the layers in the MXD) , or just some layers in a group ? in ArcMap Questions</title>
    <link>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329516#M4604</link>
    <description>&lt;P&gt;To insert formatted code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1689266678674.png" style="width: 546px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75345i1DB988B7B4303219/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1689266678674.png" alt="JohannesLindner_0-1689266678674.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1689266693900.png" style="width: 469px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75346i06615A9413162052/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1689266693900.png" alt="JohannesLindner_1-1689266693900.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your definition query is the same for all specified layers:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;layer_names = ["Layer A", "Layer B", "Layer E"]

mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.name in layer_names and lyr.supports("DEFINITIONQUERY"):
        lyr.definitionQuery = "INSERT_YOUR_DQ_HERE"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want different queries for the layers:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;queries = {
    "Layer A": "Query for Layer A",
    "Layer B": "Query for Layer B",
    "Layer E": "Query for Layer E",
}

mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.name in queries and lyr.supports("DEFINITIONQUERY"):
        lyr.definitionQuery = queries[lyr.name]&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 18 Sep 2023 11:20:55 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-09-18T11:20:55Z</dc:date>
    <item>
      <title>What should I change to run this python script on the specific layers only (not all the layers in the MXD) , or just some layers in a group ?</title>
      <link>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329410#M4597</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P&gt;for lyr in arcpy.mapping.ListLayers(mxd):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if lyr.supports("DEFINITIONQUERY"):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;lyr.definitionQuery = "INSERT_YOUR_DQ_HERE"&lt;/P&gt;</description>
      <pubDate>Sun, 17 Sep 2023 19:09:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329410#M4597</guid>
      <dc:creator>MAMDOUHZALAKY</dc:creator>
      <dc:date>2023-09-17T19:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: What should I change to run this python script on the specific layers only (not all the layers in the MXD) , or just some layers in a group ?</title>
      <link>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329448#M4599</link>
      <description>&lt;P&gt;For example, maybe try the following:&lt;/P&gt;&lt;P&gt;For file geodatabase (gdb) or shapefile:&lt;BR /&gt;lyr.definitionQuery = '"Docket"' + " = " + "'1254-2017'"&lt;BR /&gt;or for personal gdb&lt;BR /&gt;lyr.definitionQuery = '[Docket]' + " = " + "'1254-2017'"&lt;/P&gt;&lt;P&gt;-Jeff&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 04:00:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329448#M4599</guid>
      <dc:creator>JeffHouser</dc:creator>
      <dc:date>2023-09-18T04:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: What should I change to run this python script on the specific layers only (not all the layers in the MXD) , or just some layers in a group ?</title>
      <link>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329472#M4601</link>
      <description>&lt;P&gt;Can you explain to me with more details .... what should i replace in my python script to do what i want ? I do not understand&amp;nbsp;&lt;SPAN&gt;Docket"' + " = " + "'1254-2017'" !!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 06:49:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329472#M4601</guid>
      <dc:creator>MAMDOUHZALAKY</dc:creator>
      <dc:date>2023-09-18T06:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: What should I change to run this python script on the specific layers only (not all the layers in the MXD) , or just some layers in a group ?</title>
      <link>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329516#M4604</link>
      <description>&lt;P&gt;To insert formatted code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1689266678674.png" style="width: 546px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75345i1DB988B7B4303219/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1689266678674.png" alt="JohannesLindner_0-1689266678674.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1689266693900.png" style="width: 469px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75346i06615A9413162052/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1689266693900.png" alt="JohannesLindner_1-1689266693900.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your definition query is the same for all specified layers:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;layer_names = ["Layer A", "Layer B", "Layer E"]

mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.name in layer_names and lyr.supports("DEFINITIONQUERY"):
        lyr.definitionQuery = "INSERT_YOUR_DQ_HERE"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want different queries for the layers:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;queries = {
    "Layer A": "Query for Layer A",
    "Layer B": "Query for Layer B",
    "Layer E": "Query for Layer E",
}

mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.name in queries and lyr.supports("DEFINITIONQUERY"):
        lyr.definitionQuery = queries[lyr.name]&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 18 Sep 2023 11:20:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329516#M4604</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-09-18T11:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: What should I change to run this python script on the specific layers only (not all the layers in the MXD) , or just some layers in a group ?</title>
      <link>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329570#M4605</link>
      <description>&lt;P&gt;Docket = field in the layers attribute file.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'1254-2017' = is a specific txt value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please also refer to JL's post...&lt;SPAN class=""&gt;&amp;nbsp;Great info&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-Jeff&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 13:26:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/what-should-i-change-to-run-this-python-script-on/m-p/1329570#M4605</guid>
      <dc:creator>JeffHouser</dc:creator>
      <dc:date>2023-09-18T13:26:06Z</dc:date>
    </item>
  </channel>
</rss>

