Dealing with Group Layers in scripts

Discussion created by rubinsty on Jun 28, 2011
Latest reply on Jun 30, 2011 by rubinsty

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)?

Thanks in Advance.