I have a large number of groups created, with each group having many layers. I have looked for a way to set a definition query for all the layers in each group but haven't found anything. Is it even possible, maybe with model builder or python? I have ArcMap 9.3 and 10.
This function should handle this.
Copy paste into the arcpy window and it will be available.
Change definition to "OBJECTID = 1" for all feature layers in group "Test" in the current map
Same change, but in the map stored at "C:\test.mxd"
Clear definitions on all feature layers in group "Test"
Set definition on all feature layers in current map
Clear all definitions in current map
Clear all definitions in map at "C:\text.mxd"
This function will also scan nested groups, matching on any layer of the group nesting.
If you want this to be an importable script into ArcMap, save this to a .py file in the pythonpath. e.g. save as definitionByGroup.py and then import and use with: