PDA

View Full Version : Select objects by modifier - possible?


James Cleaveland
03-18-2005, 07:21 PM
Is it possible to select objects by modifier? What I'm trying to do right now is have a script that takes existing objects and applies a modifier to them with some set values that the user can use spinners to manipulate... all objects that are modified go to a list, which the user can click between and manipulate. The problem of course is that when you close MAX, say you want to go back into that scene and manipulate the objects further, and you can't, because they were stored in the globals of the script during the last session, which were wiped when you closed max!

I could script an option where the user could go in and 'pick' the objects back into the list, but I just wish they could press a button and have it done for them! A select by modifier function would be great, but I just can't seem to write it... and am wondering if its possible? Or is there a possible workaround that you guys can see?

have a nice day! hope you can help.

ofer_z
03-18-2005, 08:00 PM
here's a little functions to do this:


-- get a list of object that has a modifier of class mod from the objs list
fn getObjsUsingMod objs mod =
(
for o in objs where ((findItem (for m in o.modifiers collect classOf m) mod) > 0)collect o
)

-- example of usage: get all objects with bend modifier
getObjsUsingMod $objects bend

-- example of usage: get all objects in selection with bend modifier
getObjsUsingMod selection bend



hOpe this helps,
o

James Cleaveland
03-19-2005, 01:57 AM
this is just what I was looking for, thanks so much -
hard to grasp at first, but after a few readthroughs it started to make sense... thanks so much, just this little line opens up the world of for loops for me; I never quite understood their capacity until now. I've just gotten by on if loops and simple functions until now.

thanks again!

Bobo
03-19-2005, 08:26 PM
this is just what I was looking for, thanks so much -
hard to grasp at first, but after a few readthroughs it started to make sense... thanks so much, just this little line opens up the world of for loops for me; I never quite understood their capacity until now. I've just gotten by on if loops and simple functions until now.

thanks again!


Shameless plug, I know, but just yesterday CG Academy released a MAXScript DVD (http://www.cg-academy.net/pages/dvds_MAXScript_intermediate_2/dvds_maxscript_fundamentals_02.htm) where this and much more is explained in 3 hours and 13 minutes of practical examples by yours truly.
When I saw your question, I was like "Hey, people really ask about these things!" :)

FOR loops are MIGHTY, the more objects/materials/controllers/whatever in the scene, the more time they save you!

CGTalk Moderation
03-19-2005, 08:26 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.