ScriptSpot

Forum topic · General Scripting

Selecting Node + Children in Script

By lightcube · 2010-12-15

Description

I am having problems understanding some (seemingly) simple MAXScript techniques. I'm still fairly new to MAXScript.

If I type into the listener:

 select $/...*

The node and all of its children are selected. However, inside my scripts, I am selecting not with the $.

This works to select the object:

select myStruct.target

But the following is NOT working and is causing the script to fail to run at all:

select myStruct.target/...*

I'm obviously missing something.

I tried the following but it simply selects everything in the scene:

select myStruct.target

 select $/...*

Thanks in advance for all input.

Comments (3)

each rule has exception

Anubis · 2010-12-17

Yes, you are fully right to avoid execute(), i run from it as from plague, but each rule has exception. You can wrote recursive funcion to collect the hierarchy calling children array, but it will works more slow in complex hierarchy than execute.

Thank you... that is the same

lightcube · 2010-12-16

Thank you Anubis... that is the same solution Steve Curley gave over in the Autodesk Area MAXScript forums. It surprised me since I have always learned to avoid using the execute() equivalent in other languages. I expected there to be a better solution...

Thanks, though.

Anubis · 2010-12-16

Pathname Literals not work with ref. vars, i.e.

select $Dummy001...* -- this would work
obj = $Dummy001 ; select obj...* -- this Not

-- possible workaround...
cmd = "select $" + myStruct.target.name + "...*"

execute cmd -- or...
readExpr (cmd as stringStream)

(hope this help)