AnsweredAssumed Answered

Apply a definition query to a Layer Group

Question asked by pcoventry_bouldercounty on Nov 9, 2017
Latest reply on Nov 9, 2017 by pcoventry_bouldercounty

I'm trying to apply a definition query to a Layer Group (containing several feature classes) by using the following script where I would simply change the values for my 'SUBCODE' field


import arcpy

#Variables to form defintion query
field = '"SUBCODE"'
values = "'1152','1153'"
#concatenate query syntax
queryStr = str(field) + "=" + str(value)
#Specify the aprx project (CURRENT), dataframe (Layers)
m = p.listMaps("Map_3D")[0]
#Apply defintion query to specified layer group
for lyr in m.listLayers( "3D Layers")[0]:
    if lyr.supports("DEFINITIONQUERY"):
    lyr.definitionQuery = queryStr
del aprx

This is the error I'm receiving when I run this in Arcpy:


Traceback (most recent call last):
  File "<string>", line 12, in <module>
IndexError: list index out of range

 There are some migration from arcpy.mapping to ArcGIS Pro I'm having trouble with -

Any help on this script would be greatly appreciated!