PDA

View Full Version : Looping through object pathNames in a script?


loocas
04-24-2008, 01:09 PM
Hi there,

I've bumped into a, I believe a trivial, problem. I cannot find a way to loop through object's hierarchy in a script.

I mean, when I call the path this way: $objName/* to find direct children of the "objName" object, it all works, however, when assigning the obj to a variable, let's say "tmp" it doesn't work: tmp = $selection; tmp/* it either hangs the script or prints "OK".

Where's the problem?

The thing is, I need to write some code that goes through selection in a hierarchical manner and I thought (at first) that the pathnames might be of some help. I can loop through ".children" property of the objects, but if you have any better ideas, I'd be very glad to hear them ;)

Thanks in advance, cheers,

- loocas

ZeBoxx2
04-24-2008, 02:37 PM
It doesn't actually hang, but when you type...

tmp/*
It thinks you're opening a comment.. as in

tmp/*this is a temp variable!*/

Typing */ should give you control back over maxscript.

As for the actual question - .children is probably it, short of...
execute ("$" + tmp.name + "/*")
or
execute (exprForMaxObject tmp + "/*")
...shenanigans.

loocas
04-29-2008, 06:24 PM
It doesn't actually hang, but when you type...

tmp/*
It thinks you're opening a comment.. as in

tmp/*this is a temp variable!*/

Typing */ should give you control back over maxscript.

As for the actual question - .children is probably it, short of...
execute ("$" + tmp.name + "/*")
or
execute (exprForMaxObject tmp + "/*")
...shenanigans.

Thanks a lot, mate! :thumbsup: I didn't realize the /* consequence, my bad. The .children property works fine, but the path gives a bit more flexibility imho.

Anyways, your examples are 100% useful, so, thanks for those, man! :buttrock:

CGTalk Moderation
04-29-2008, 06:24 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.