[Closed] All group members
Hey, I need your help. Everything seams to be obvious, and very easy, but I can’t get to the solution.
I have a group of objects, and I have access only to the top head of this group, let’s say Dummy:Group01
How can I get all it’s members?
PS: this is not the situation when this group is selected. I should not select it.
I could select the head and automatically all it’s members could get selected and the solution is ready. But I need to keep at this moment other selection!
easy solution is
allmembers = join #() groupheadnode
the right solution is different. but most likely you have to be OK with easy solution
Thank you, Denis!
By the way, how to call correctly, to be understandable by all max users, Open Group Red Boxes?
http://forums.cgsociety.org/showthread.php?f=98&t=1151850&highlight=isgrouphead
http://forums.cgsociety.org/showthread.php?f=98&t=1110844&highlight=isgrouphead
check these threads…
the easy way is not correct because it collects all “children” of a node. it’s true that all group members are children of group head, but it’s not true that all children are group members
I hope so. But Denis always has something to add and thread discussion goes crazy
Just kidding. I like the way he motivates people to make the effort to learn something new.
With him is always a challenge (ps. links above show that)
so… any idea how to find ALL and ONLY group members for “Group003” head in this setup:
delete objects
(
b0 = box pos:[40,0,0] wirecolor:orange
b1 = box pos:[80,0,0] wirecolor:orange
g0 = group #(b0,b1)
b2 = box pos:[40,40,0] wirecolor:green
b3 = box pos:[80,40,0] wirecolor:green
g1 = group #(b2,b3)
g2 = group #(g0,g1)
in (box pos:[0,0,40] wirecolor:blue) (g2.parent = box pos:[0,0,80] wirecolor:red)
for g in #(g0,g1,g2) do setGroupOpen g on
in b0 (box pos:[0,0,80] wirecolor:blue)
in g0 (box pos:[0,0,120] wirecolor:blue)
a0 = box pos:[0,40,80]
a1 = box pos:[0,80,80]
g3 = group #(a0,a1)
g3.parent = g2
)
And the challenge begins. First try
grp = datapair master:null slaves:#()
for o in objects where isgrouphead o do
(
if canconvertto o.parent Editable_mesh then grp.master = o else append grp.slaves o
)
grp
Something like this maybe ?
mapped fn open_close groups state: = setGroupOpen groups state
fn findRealGroupMembers groupNode = if isGroupHead groupNode do
(
real_group_members = #()
closed_groups = for g in groupNode where isgrouphead g and not isOpenGroupHead g collect g
if closed_groups.count > 0 do open_close closed_groups state:on
for grp in groupNode.children where isgrouphead grp and isOpenGroupMember grp do
(
for m in grp where isOpenGroupMember m do append real_group_members m
)
if closed_groups.count > 0 do open_close closed_groups state:off
real_group_members
)
findRealGroupMembers $Group003
there are might be any nodes… we don’t have to check if they are geometry or not.
you can change all boxes to points for example. it doesn’t matter.