[Closed] How to select a hierarchy
You’re right, the function you provided operates on the ‘children’ array in-place (instead of having the function call itself repeatedly) thereby growing it automatically on each iteration. Having said this, I do think a recursive function would be slightly faster.
Martijn
Indeed I am – mea culpa; adjusting the array used for a loop, could’ve sworn that didn’t work – time to review scripts :curious:
Sounds like it’s time someone is going to iterate the functions a few thousand times and see by how many milliseconds one differs from another…
But I feel “my” solution should win the creativity price. :arteest:
-Johan
If no one gets to it first I will TRY to remember to do a speed test this weekend and put it on the tech-artists.org wiki.
We use this (it passes by reference), though I may change the function to something else if it is faster, based on this thread! It uses by-reference parameters so I THINK it is more memory efficient than a regular recursive that passes an ever-growing number of arrays.
fn getAllChildren obj &arr:#() =
(
for c in obj.children do
(
append arr c
getAllChildren c arr:arr
)
arr
)
select (getAllChildren $ arr:(selection as array))
Hi guys, i’m glad to see that my question stirred up an interesting conversation. It quickly went over this noobs head though.
I’m sorry but i don’t understand what this line does exactly and i really don’t understand it’s structure.
execute (“$’” + (obj.name)+”’/”+(if includeParent then “” else “/”)+”…/”)
Could somebody explain it to me please. Thanks everyone for you help and your time. Have a good day