PDA

View Full Version : selecting objects by name


dieselll
05-12-2009, 09:36 AM
i want to write a for loop which chooses sertain objects according to their name .... example
i want to select all objects will name box like box01 box02 box 03 ..... but if their is sphere01 it will not be selected in the loop ....
thx in advance :)

ZeBoxx2
05-12-2009, 09:44 AM
select (getNodeByName "Box01") -- selects only Box01


or...


select (execute ("$Box*")) -- selects Box01, Box02, BoxTop, BoxEtc


or...


for o in objects do (
-- selects Box01, Box02, BoxTop, BoxEtc, without using an execute()
if (matchPattern o.name pattern:"Box*") do ( selectMore o )
)


from either of those it's just some string manipulation to get the ones you want

SyncViewS
05-12-2009, 09:53 AM
Hi dieselll,
take a look at "Pathname Literals" in MaxScript Reference, probably you don't need a loop.

aw :/ (late)

Richard, you forgot:
select (for item in $Box* collect item):D

- Enrico

dieselll
05-12-2009, 10:15 AM
yea it really works but unfortunetly i cant integrate it with the rest of my script ....

this is the script i am working on now

for i in selection do
(
addModifier i (uvwmap maptype:4 MapChannel:2)

)
for o in getclassinstances VrayMtl do
(
try
(
mtlBrowser.browseFrom #selected
o.texmap_diffuse.coords.mapchannel = 2
Showtexturemap o o.texmap_diffuse on
)
catch()
)

and i want to select objects by name instead of selecting it by mouse .... can anybody help me plz :)

ZeBoxx2
05-12-2009, 11:28 AM
Hi dieselll,
Richard, you forgot:
select (for item in $Box* collect item):D


Naw, that's the same as..

select (execute ("$Box*"))


more to the point.. your line there collapses to:
select $Box*
The only reason for the execute is if you need things named dynamically, which requires the string manipulations implied :)

SyncViewS
05-12-2009, 11:30 AM
You outsmarted me, it was just a joke :D

ZeBoxx2
05-12-2009, 11:30 AM
i want to select objects by name instead of selecting it by mouse .... can anybody help me plz



Just replace....

for i in selection do


...with...

for i in $Box* do

?

Edit: ... which of course you already got answered in:
http://forums.cgsociety.org/showthread.php?p=5860417#post5860417

Try not to post the same question to multiple threads ;)

ZeBoxx2
05-12-2009, 11:36 AM
You outsmarted me, it was just a joke :D
A horse and a cow enter a bar... ;)

SyncViewS
05-12-2009, 11:49 AM
Sorry to be off topic, but couldn't resist... Richard, are you referring to this (http://www.bearingyourarts.com/scripts/acowandahorse.pdf)? Well, that's brilliant! :D

- Enrico

ZeBoxx2
05-12-2009, 12:43 PM
:thumbsup:

short posts are awesome.. darn forum.

so err.. diesell - all sorted?

CGTalk Moderation
05-12-2009, 12:43 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.