Notifications
Clear all

[Closed] Get all children

I’m sure this is one when using an Out Parameter would be a good idea, but I can’t get it doing what I want in less lines of code. How can I make this work without having to predefine an empty array? I want to get all children of the selected objects including the selection.

fn getChildren theObjs newObjs=
(
	for o in theObjs do
	(
		append newObjs o
		getChildren o.children newObjs
	)
	newObjs
)
newObjs = #()
getChildren (selection as array) newObjs
3 Replies

Try using collect

previous thread

mapped fn getAllChildren node &children = (join children node.children)
/*
a = #()
getAllChildren selection &a
a
*/

there is the same with foolproof

mapped fn getAllChildren node children = (if isvalidnode node and iskindof children Array do join children node.children)