Dealing with Group Layers in Python scripts

Discussion created by rubinsty on Jul 4, 2011
Latest reply on Jul 7, 2011 by cfox-esristaff

I'm working on ArcGIS 9.3.1 and I run a python script which basically does a "select by location" query to several SDE layers which appear on the ArcMAP TOC (using a polygon shapefile the user points to) and copies the selected features to a new shapefile.

THE PROBLEM IS that some layers are within a group layer, and then the script gives a error stating :

<class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid.
ERROR 000840: The value is not a Feature Layer.
Failed to execute (SelectLayerByLocation)

now I understand that group layer is not a feature Layer and that SelectLayerByLocation only accepts feature Layers, that's where my question fits in:

Question: How can I reach a feature layer inside a Group layer using python code? or better yet, how can I tell what kind of layer I'm dealing with (Feature\group layer) using python code(describe method doesn't work on group)?  I'm running the script from a tool I built in ArcToolBox.

(this is a repost of a message I posted here, on geoprocessing forum, as I didn't find an answer and was hoping I'd find one here. thanks)

Thanks in Advance.