There's a very common keyword, in most programming languages, that goes through a collection of things (like the list of the selected objects): for
Now for the basic example. Let's say you want to change the radius of multiple spheres ! In MAXScript it would look like that:
for i in selection do i.radius = 5
Just open the MAXScript Listener and paste this in. Once you press enter your selected spheres should have a radius of 5, and Max should gratify with a satisfying blue OK. Max only gets more verbose if things don't work as planned.How to know the name of the parameter I hear? Well there are a few ways.
$.segs = 10
From there you just replace radius by segs and you're set! As you can see the parameter name in MAXScript isn't always the same as the one displayed in the interface, so you can't always just guess.Another way is to ask Max to show you the list of the attributes of the selected object with the function show:
show $
.smooth : boolean
.radius : float
.segs : integer
.mapcoords : boolean
.slice : boolean
.hemisphere : float
.sliceFrom : angle
.sliceTo : angle
.chop : integer
.recenter : boolean
.realWorldMapSize : boolean
false
That can come in handy! The $ sign stands for the current selection.Of course you'll also find all the properties of objects in Max Help, with some info about them if you're lucky!
Note that for a lot of basic attributes like radius ou segs, you can directly type:
$.segs = 10
That's called a Mapped Function and can be faster than a for loop, but doesn't always work. For example, if you try to assign an animation controller on several objects, you'll have to resort to using a loop.That's it for today, it's fairly simple but can save your life from time to time !
No comments:
Post a Comment