Notifications
Clear all

[Closed] Looping through object pathNames in a script?

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
2 Replies

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.

1 Reply
(@loocas)
Joined: 11 months ago

Posts: 0

Thanks a lot, mate! 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: