You can force the settings of contexts such as coordsys , animate , time , and so on, to be "sticky."
The settings will stay active for any code execution that follows, up until the point you change them or override them with a context prefix for an expression.
This is particularly useful when working in the Listener, allowing you to set a context and then perform several interactive operations in that context without prefixing each with the desired context construct.
Establishing a sticky context is accomplished with the set construct:
where <context> is one of the MAXScript context prefixes: animate , time , in , coordsys , about , level , or undo .
This turns animate on and sets the current time to frame 30 after which any number of interactive operations can be performed that will generate animation at frame 30.
The modes are then returned to default.
As shown in this example, certain MAXScript contexts permit syntactic variants to make the set construct read clearly.
The time context can be set to off , signifying the current value of the 3ds Max time slider is to be used.
All the set constructs are expressions that yield the context setting that was in force at the time the new context was set.
This allows you to simulate the standard nested forms of these constructs by storing the old context in a variable and using that to restore the context later.
You can also force several of the contexts back to their default states by specifying #default as their parameter.
The set constructs for which you can specify #default are: animate , in , coordsys , and level .
When using the set undo on construct to enable the undoing of scripted changes in the Listener, undo granularity is a top-level expression.
Every time you evaluate an expression or sequence of selected expressions with the ENTER or Number-Pad ENTER key, a single entry is added to the Undo stack.