Notifications
Clear all

[Closed] Get/Select group members?

I’m making a script that will take the selection, filter out anything that isnt a group, and then grab and store references to the members of each group. This then picks a random member of each group and outputs it. It’s a mix/match script for making a character from sets of parts, so I have a group of heads, a group of torsos, etc. and this thing will output unique characters (it will store something with each character or in a dummy so it knows whether its’ come up with a unique combination).

My problem is I don’t know how to query a group for it’s nodes, or a node for it’s group. I can ask whether a node is a group member, but not what group it actually belongs to.

Anyone know?

2 Replies

Think you need obj.parent
It will output undefined if it’s not in a group and a Dummy object if it is.

.children on the group should give you an array with the node members inside a group

for o in objects where isGroupHead o do print o.children