As you alluded to, "group" nodes really are just transform
nodes, with no real distinction.
The clearest distinction I can think of however would be that its children must be comprised entirely of other transform
nodes. Parenting a shape node under a "group" will no longer be considered a "group"
First, your selection of transform
nodes. I assume you already have something along these lines:
selection = pymel.core.ls(selection=True, transforms=True)
Next, a function to check if a given transform is itself a "group".
Iterate over all the children of a given node, returning False
if any of them aren't transform
. Otherwise return True
.
def is_group(node):
children = node.getChildren()
for child in children:
if type(child) is not pymel.core.nodetypes.Transform:
return False
return True
Now you just need to filter the selection, in one of the following two ways, depending on which style you find most clear:
selection = filter(is_group, selection)
or
selection = [node for node in selection if is_group(node)]