The pymxs Python module provides a wrapper for the MAXScript engine, and exposes virtually all the interfaces, globals, and classes available in MAXScript.
The undo system is exposed in pymxs with:
As with MAXScript, operations run through pymxs are not recorded by the undo system. Undo must be specifically enabled. Undoable pymxs operations appear as items labeled MAXScript in the 3ds Max Undo menu.
For example, to create a teapot, change its position, and then undo the change:
import pymxs rt = pymxs.runtime # this will not be undoable: with pymxs.undo(False): t = rt.Teapot() with pymxs.undo(True): t.pos = rt.Point3(20,20,20) pymxs.run_undo() # undo the position pymxs.run_redo() # redo the position
You cannot call pymxs.runtime commands directly on a worker thread, as this will cause a runtime exception. However, pymxs has a mxstoken() function to support multi-threading by providing a synchronization mechanism between worker threads.
For an example of this approach, see the example <maxdirectory>\scripts\Python\demoMXSToken.py.