select all the children?

how do I select an object AND all it's children (objects linked to it) in the hierarchy?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mariokart64n's picture

sorry for the bump, I had a

sorry for the bump, I had a need to find children and wrote a function that does so
please feel free to optimize and improve the function

fn grabchildren abone = (
childArray = #()
tempArray = #()
for z = 1 to abone.children.count do (
append tempArray abone.children[z])
while tempArray.count!=0 do (
abone = tempArray[tempArray.count]
append childArray abone
deleteitem tempArray tempArray.count
for z = 1 to abone.children.count do (
append tempArray abone.children[z]))
return childArray
)

*example
grabchildren $Bone001

and it would return all its children

barigazy's picture

shorter version

select $Bone001/.../*
--or
select $Bone001...*

bga

juxtapOZ's picture

Well it's been a while since

Well it's been a while since this post (now fluent in maxscript), but i discovered this sweet little command shortly after, which saves you from having max run through a for loop just to find the hierarchy.

select $/...*
or even,
select $...*

Go figure, it's listed under a page titled "Pathname Literals" rather than simply "hierarchy" or something else pleasantly easy to find.
http://www.cgplusplus.com/online-reference/maxscript-reference/source/pa...

hopefully this saves any newcomers a few more strands of hair. :)

OmniZed.com

martinskinner's picture

Does this do the trick?

Does this do the trick? -

for i in selection do
(
selectmore i.children
)

I'm not 100% clear as to what you are trying to do, but this ran through selected objects and added to the selection all of their children whilst retaining the initial objects as selected.

Hope it's of help.

Martin
www.martinskinner.co.uk

though re-reading the above post it's pretty much the same script minus the if clause and not packaged as a function. So are either of them what was initially wanted?

juxtapOZ's picture

yeah i've run into the same

yeah i've run into the same problem...time and time again.
if you just want a hotkey, no problem.

customize user interface > keyboard tab >  ...and search for Select Children
then just set a hotkey (i have mine set to Ctrl + PgDown)

i think max's default for Select Child is PgDown.

But the frustrating part is trying to call this action/selection from MaxScript; for automating hierarchical selections to run any number of procedures on that array.
The reason for this, is because Max's keyboard commands does not appear to be accurately reflexed in MaxScript commands.

select $.children (acts like Keyboard Command / Select Child)

select $.child (is an unknown property)

Turning on echo all or the macrorecorder while performing the Keyboard Command, rarely serves its purpose b/c it doesn't really show you what Max is actually receiving.
You're likely to recieve something about actionman, which, as far as i know, is not a valid script command, unless you want to save/load the .kbd file. 

i'm still trying to get used to MaxScript *hence the frustration* (so please correct me if i'm wrong), but you'll have to recreate the key board command by cycling through a selected node's children's children's grandchildren's etc... with a FOR loop, to populate the array.

 

edit:

 

ok...starting to make a little more sense now :)

 

    function selectHierarchy =
    (
    for p in selection do
    (
    if p.children != undefined do
    (
    selectmore p.children
    )
    )
    )
    selectHierarchy()

 

OmniZed.com

martinskinner's picture

selectmore $.children --

selectmore $.children

-- this adds the children of the selected object to the selection.

but of course you could just double left click on the parent object and that selects both it and all it's children in the hierarchy... :)

nycwtorres's picture

almost.. that only selects

almost.. that only selects one level of children. I want to select ALL the children

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.