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
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
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
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?
#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?
#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
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
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.
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
)
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
)
fuc…I miss that combo.
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.