MAXScript FAQ > Working With Scene Nodes > How Do I instance Modifiers and Controllers inside the same object? |
Is there a function for copying a modifier and then pasting an instance of it onto the same object? I can copy and paste it but not as an instance.
Reading an existing modifier through MAXScript and applying the SAME modifier will create an instance automatically.
So you just read ANY value in MAXScript - using it again means INSTANCE it.
you are adding a unique modifier to every object, because the constructor expression (Bend()) is evaluated n times where n is the number of selected objects.
then you are creating a single modifier, storing it into a variable and then applying an instance of it to each object in the selection.
Even better, mapped operations are also good for instancing. The same result as above can be achieved with much less code:
adds the SAME Bend modifier as instance to all selected objects, because the constructor expression (Bend()) is evaluated only once and is then applied in an internal loop as instance to every object in the collection.
Obviously, you can instance between objects, too.
You can also apply the same technique to controllers. For example, if you want to instance the controller of the X_Position and assign it to the Bend Angle, then you can say:
Now if you move the object along X, the bend angle will change accordingly.