I have a script that allows me apply a single SQL Definition Query to all feature classes within a particular Group Layer. For ease of input for others in the office, I changed this into a model tool, and so rather than typing these values into the python script itself, a dialog pops up with two text boxes/drop down menus.
One of the input boxes is just a SQL Expression data type, and the other uses the "Group Layer" data type, so it populates a drop down list of all group layers within the map. Using this method, the drop down does populate with all the map's group layers and I am able to select a group layer. However, the script doesn't work (though it doesn't throw any errors). If I instead type the Group Layer name directly into the script with quotes around it, it works properly. What am I doing wrong? I'm sure it's something simple, but I'm new to scripting. Script code as follows:
groupLayer = arcpy.GetParameterAsText(0) sql = arcpy.GetParameterAsText(1) mxd = arcpy.mapping.MapDocument ("CURRENT") for lyr in arcpy.mapping.ListLayers(mxd): if not lyr.isGroupLayer: continue if not lyr.name == groupLayer: continue for subLyr in lyr: subLyr.definitionQuery = sql