<?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 multiple definition query for multiple layers in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/multiple-definition-query-for-multiple-layers/m-p/1397036#M70072</link>
    <description>&lt;P&gt;I need to write python code to apply definition query for all layers at once, i already tried some code which i insert it below but it makes a new layers&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Set the workspace (change to your desired geodatabase or folder)
arcpy.env.workspace = r"D:\abo-ammar\geoParcel.gdb"

# List of feature classes (change to your desired feature class names)
feature_classes = ["parcels_corner", "parcels_dimension", "LINE_AMLAK", "Parcels"]

# Define the common query expression (change to your desired query)
query_expression = "parcel_no = 2"

# Loop through each feature class and apply the definition query
for feature_class in feature_classes:
# Get the existing layer
layer = arcpy.management.MakeFeatureLayer(feature_class, f"{feature_class}_Layer", query_expression)
print(f"Definition query applied to {feature_class}.")

# Print a success message
print("Definition queries applied to all specified feature classes.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to know how to apply the same code but over the current layers not with generation of a copy of each layer&lt;/P&gt;</description>
    <pubDate>Sun, 17 Mar 2024 11:47:55 GMT</pubDate>
    <dc:creator>marklee1869</dc:creator>
    <dc:date>2024-03-17T11:47:55Z</dc:date>
    <item>
      <title>multiple definition query for multiple layers</title>
      <link>https://community.esri.com/t5/python-questions/multiple-definition-query-for-multiple-layers/m-p/1397036#M70072</link>
      <description>&lt;P&gt;I need to write python code to apply definition query for all layers at once, i already tried some code which i insert it below but it makes a new layers&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Set the workspace (change to your desired geodatabase or folder)
arcpy.env.workspace = r"D:\abo-ammar\geoParcel.gdb"

# List of feature classes (change to your desired feature class names)
feature_classes = ["parcels_corner", "parcels_dimension", "LINE_AMLAK", "Parcels"]

# Define the common query expression (change to your desired query)
query_expression = "parcel_no = 2"

# Loop through each feature class and apply the definition query
for feature_class in feature_classes:
# Get the existing layer
layer = arcpy.management.MakeFeatureLayer(feature_class, f"{feature_class}_Layer", query_expression)
print(f"Definition query applied to {feature_class}.")

# Print a success message
print("Definition queries applied to all specified feature classes.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to know how to apply the same code but over the current layers not with generation of a copy of each layer&lt;/P&gt;</description>
      <pubDate>Sun, 17 Mar 2024 11:47:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-definition-query-for-multiple-layers/m-p/1397036#M70072</guid>
      <dc:creator>marklee1869</dc:creator>
      <dc:date>2024-03-17T11:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: multiple definition query for multiple layers</title>
      <link>https://community.esri.com/t5/python-questions/multiple-definition-query-for-multiple-layers/m-p/1397162#M70074</link>
      <description>&lt;P&gt;Dear marklee,&lt;/P&gt;&lt;P&gt;I hope you are doing well,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you just need to delete the "_layer" from your second element in the arcpy.management.MakeFeatureLayer function.&lt;/P&gt;&lt;P&gt;# Set the workspace (change to your desired geodatabase or folder)&lt;BR /&gt;arcpy.env.workspace = r"D:\abo-ammar\geoParcel.gdb"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# List of feature classes (change to your desired feature class names)&lt;BR /&gt;feature_classes = ["parcels_corner", "parcels_dimension", "LINE_AMLAK", "Parcels"]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Define the common query expression (change to your desired query)&lt;BR /&gt;query_expression = "parcel_no = 2"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Loop through each feature class and apply the definition query&lt;BR /&gt;for feature_class in feature_classes:&lt;BR /&gt;# Get the existing layer&lt;BR /&gt;layer = arcpy.management.MakeFeatureLayer(feature_class, f"{feature_class}", query_expression)&lt;BR /&gt;print(f"Definition query applied to {feature_class}.")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Print a success message&lt;BR /&gt;print("Definition queries applied to all specified feature classes.")&lt;BR /&gt;&lt;BR /&gt;Good luck&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 11:04:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/multiple-definition-query-for-multiple-layers/m-p/1397162#M70074</guid>
      <dc:creator>Amir-Sarrafzadeh-Arasi</dc:creator>
      <dc:date>2024-03-18T11:04:19Z</dc:date>
    </item>
  </channel>
</rss>

