Notifications
Clear all
[Closed] Using the for variable to select objects by name
Jan 20, 2012 6:45 pm
Hi, I’m newbie in Maxscript, and I’m trying to select objects (get the position of it) inside a for loop using their names…
like this:
for b = 1 to 8 do
(
p = $box[b].pos (for get the position of box001)
print p
)
But it doesn’t work… :curious: How can I do it??
3 Replies
Jan 20, 2012 6:45 pm
Use this:
(
for i = 1 to 8 do
(
p = ( execute ("$teapot00"+(i as string)) ).pos
print p
)
)
or this:
(
for i = 1 to 8 do
(
p = (getnodebyname ("teapot00"+(i as string))).pos
print p
)
)
Jan 20, 2012 6:45 pm
(
local searchName = "box"
local MultipleNodes = for o in objects where matchpattern o.name pattern:("*"+searchName +"*") collect o
for obj in MultipleNodes do print (obj.name + ": " + obj.pos as string)
)
Basically you change searchName to whatever name you are looking for. The * is a wild card, so in this case you could have something called ‘aboxz’ and it would add it to the list. Remove them to make it more specific.
Hope this helps