I am about to save copies of all of the layers in my mxd. I only want to save the top level group layers though. I have some group layers within group layers - I dont want to save them individually. So far I can export all group layers like this:
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.isGroupLayer == True:
lyr.saveACopy(lyr.name.replace(":"," -").replace("&","and").replace(">","") + ".lyr")
What I'm looking for is either a property that says what level the layer is on so I could say if layer level = top level...
(instread of if lyr.isGroupLayer == True:
) or a property that says that the layer is within a group layer so I could say if lyr.isInGroupLayer == False:
.
I suppose this could be in my for loop or a change to the mapping.ListLayers
Any ideas?