Notifications
Clear all

[Closed] select hierarchy

Hello;

This question can be a basic for you, I just can’t find the command in the SDK Guidelines, but I’m sure it exists. I wanna find the scripting equivalent for double clicking an object (select hierarchy).
I wrote a recursive function to go through all an object hierarchy and select them, but it’s far too slow :wise:

That’s all, thanks in advance !

3 Replies

Nham,

Give this a try. My comments should speak for themselves, if not don’t hesitate to ask.

Cheers,
Martijn

(

/*
	collects all children recursively. arguments:
	
	obj		-- the object to collect its children
	allChildren	-- by-reference argument used to store child objects
	includeParent	-- whether the original parent object should be included
	includeHidden	-- whether hidden objects should be included

*/
fn collectChildren obj &allChildren includeParent:false includeHidden:false =
(
	-- check if object should be collected
	if (includeHidden or not obj.isHiddenInVpt) and includeParent and finditem allChildren obj == 0 then
		append allChildren obj

	-- collect current object's children
	for c in obj.children do collectChildren c &allChildren includeParent:true includeHidden:includeHidden
)


-- initialize children array
local allChildren = #()

-- collect all children
for obj in selection do collectChildren obj &allChildren

-- select them
select allChildren

)

Thanks a lot Magicm, it’s more or less the script I wrote. Actually I was just sure this command was implemented by default. I was wrong obviously :D.

Thanks for sharing and making things clearer to me.

Cheers

actionMan.executeAction 0 “40180”