Notifications
Clear all

[Closed] List Children

Hello,

Is there a way to list all the children of an object, including the children’s children and so on down the heirarchy? Just like checking select subtree in the select objects window, only I want to list the subtree and put it into a variable.

Thanks,
Stev

3 Replies

Hi Stev,
Sure you need to build a recursive function. Try this…

fn getChildrenRecursive obj arr=
 (
 if obj.children.count > 0 then
  (
  for c in obj.children do
   (
   append arrObj c
   getChildrenRecursive c arr
   )
  )
 )
 
arrObj = #()
getChildrenRecursive $ arrObj
print arrObj

That works perfectly!

Thanks,
Stev

amazing, I just couldn’t imagine it was possible to use a function within itself !
Good news !!
thanks