arcpy property layer.isGroupLayer not working as expected

335
2
08-10-2020 12:37 PM
Arne_Gelfert
Regular Contributor

Working with arcpy for ArcGIS Pro and trying to manipulate a map in APRX project before converting to PDF. Just stumbled across my own post from earlier in the year... How to reorder/add/remove layers APRX map programmatically? So maybe I'm still not understanding something or there is something wrong.

I'm trying to do something similar to what's explained in the post about flattening Group Layers for MXD. But a group layer set up in ArcGIS Pro 2.5 will return ...

map.listLayers('My Group Layer').isGroupLayer
>>> False

To me the group layer should be the 'Parent' as it is in ArcMap or Pro, so the parent should return isGroupLayer = True. Even assuming that arcpy considers the 'Child' the GroupLayer,for me isGroupLayer return 'False' for any/all layers in the map.

At the same time, the layer behaves like it's a GroupLayer. Setting

childLayer.visible = True

...automatically makes the parent visible, too.

Is the property isGroupLayer not working correctly, or at least not working as described here - Layer—ArcGIS Pro | Documentation  ?

Ultimately I'm trying to hide the Group Layer name from the Legend. This can be accomplished in Pro but I'm looking for a way to do this in Python and don't see anything the documentation  for LegendElement—ArcGIS Pro | Documentation.

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

from the Pro discussion, did you check the next property

A layer's longName value...

What does the table of contents for the map show? (screen grab?)


... sort of retired...
0 Kudos
Arne_Gelfert
Regular Contributor

You're referring to checking 

If the name value is equal to the longName value, the layer is not inside a group layer.

No, I didn't even catch that... I'll take a look. But it still doesn't explain how you're supposed to use isGroupLayer.

Thanks, Dan.

0 Kudos