How to pick a group object?


#71

Why do we need other nodes when you look for GroupHead.
Your first function is better then last one ei. it’s the same. Denis did not surrender


#72

Just a shot in the darkness :slight_smile:
Ok. Good night to both of you.


#73

is a group head a group member?


#74

Good night friend


#75

Yes if is nested


#76

This is my final attempt


   fn getRootGroupHead node = if isgroupMember node do
   (
   	while node != undefined and (isgrouphead node.parent or isgroupmember node) do node = node.parent
   	node
   )
   getRootGroupHead $Box001

#77

Another functions


        fn[b] getRootGroupHead[/b] node = if isgroupMember node do
        (
        	while node != undefined and (isgrouphead node.parent or isgroupmember node) do node = node.parent
        )
        fn [b]isReallyGeometry[/b] obj = isKindOf obj GeometryClass and canConvertTo obj Editable_Mesh
        fn [b]getGeometryGroupMembers[/b] grp = if isGroupHead grp do
        (
        	local childrens = execute ("$"+grp.name+"...*")
        	for c in childrens where isReallyGeometry c collect c
        )
        rootGroup = getRootGroupHead $Box001
        geoGroupMembers = getGeometryGroupMembers rootGroup
        

#78

Thanks guys for putting efforts in, I am sick today too.
I wake up 2 o’clock this afternoon and wow 6 pages of responses.
Eat my hat.
Thanks
Jack


#79

Thanks to Denis this thread has been turned into a battlefield.
If you want to learn something really cool and useful U need to jump here and survive.:slight_smile:


#80

dont know about it but …try.only


fn SS_findGroupHead node =
(
if node.parent != undefined then
	(
	if isgrouphead node.parent then return node.parent 
	)
SS_findGroupHead node.parent
)

#81

We already tried with recursive function :slight_smile:


#82

i don’t want disappoint you but both getRootGroupHead and getGeometryGroupMembers are not correct in general case.
#1 what if the node is a group head itself?
#2 what if we have more than one node with the same name as a group head?


#83

#1>>>

fn getRootGroupHead node = if isValidNode node do
(
	while node != undefined and (isgrouphead node.parent or isgroupmember node) do node = node.parent
)

#2>>> Can I use recursive fn?


#84

#1 wrong again
#2 you can use whatever you want but it doesn’t need a recursion. first time on this forum the best method was shown by LO


#85

I not have more ideas for #1
Can you show mystery code and “lo” method


#86

fn getRootGroupHead node = if isgroupmember node do
(
	while node != undefined and (not isgrouphead node or isgroupmember node) do (node = node.parent)
	node
)
fn getGeometryGroupMembers node = if isgrouphead node do
(
	for node in (join #() node) where iskindof node geometryclass and canconvertto node editable_mesh collect node 
)


#87

fuc…I miss that combo. :slight_smile:
U are right. It’s to perfect and simple to be true.
Second one… I don’t know what to say…only I can take my hat off.
Thanks Denis for this lesson.


#88

It’s my turn to thank Denis - thank you.


#89

Yeah, thanks a lot


#90

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.