MAXScript allows you to register callback scripts for all of the notification events supported by 3ds Max, such as pre/post scene file open, new, reset, scene file save, pre/post render, selection change, etc.
You can specify any number of callback scripts per notification event.
Callback scripts can be bundled into sets with user-defined IDs and can be deleted by type, by ID or by both.
Callback scripts can be specified as persistent so that they are saved and loaded with the currently open file.
The callbacks are added using the following syntax:
callbacks.addScript <callback_type_name> (<script_string> | <script_stringstream> | fileName:<filename_string>) [id:<name>] [persistent:<boolean>]
This method is used to register a new callback script. Requires as the first argument a name that specifies which type of notify event this script is associated with. The list of valid callback_type_name values is listed below.
The script is supplied either as a direct String or StringStream value containing the text of the script to run, or as a fileName: keyword argument, in which case the named file is loaded and run whenever the event notification callback occurs. You can specify either a direct string or a fileName: , but not both.
The optional id: parameter lets you tag one or a group of callbacks with a unique name so that you can remove them all as a group without interfering with other callbacks, perhaps registered by other scripted tools.
The optional persistent: parameter lets you control whether the script is saved permanently in the currently open scene file or is a global callback script that remains in place no matter what file opening and closing is performed. A true value for the parameter specifies that the script should be stored in the current file and loaded and registered for callback whenever that file is opened again. Persistent callback scripts are always removed when a new file is loaded or a reset is performed so that persistent scripts in one file don't accidentally get copied to a later file. The default for this parameter is false , indicating the script is a global script and is not persistent.
This method is used to unregister and remove one or more callback scripts.
Specifying just a callback event type name removes all the callback scripts for that event type.
Specifying just an id: removes all callback scripts in all events with that ID.
Specifying both limits the ID-based removal to the specified event type.
This method lists out the current callback scripts in the Listener window.
If the optional callback type name argument is specified in 3ds Max 2009 and higher, only callbacks of that type will be shown.
If the optional keyword argument id: is specified, only callbacks with that ID will be shown.
If both are specified, only callbacks of the type with the given ID will be shown.
This method provides a way for you to simulate one of the events and have all the callback scripts for it executed.
Within 3ds Max, the #preRenderFrame and #postRenderFrame callbacks can only be called by the renderer. These callbacks can not be called by using this method.
This method can be called in a callback script to provide additional information on the callback. The value returned by this method varies based on the callback type. If no additional information was present for the callback, a value of 'undefined' is returned.
Below are all supported Callback Event Names and the callbacks.notificationParam() values typically returned. Depending on how the broadcast is generated, a value of 'undefined' may be returned by this method instead of the value shown.
Sent when the Animate button is turned off.
Sent when the Animate button is turned on.
Sent after the tabbed render dialog has been created.
Sent after the tabbed render dialog has been deleted.
Sent whenever the common renderer parameters have changed.
Sent before the current renderer is changed, or the type of one of the renderers is changed.
Sent after the current renderer is changed, or the type of one of the renderers is changed.
Sent after the image viewer is created, but before it becomes visible. Calling callbacks.notificationParam() returns an IVFB interface which allows rollouts to be added to the Virtual Frame Buffer (a.k.a. Rendered Frame Window).
Available in 3ds Max 2009 and higher.
Sent after the image viewer becomes visible. Calling callbacks.notificationParam() returns an IVFB interface which allows rollouts to be added to the Virtual Frame Buffer (a.k.a. Rendered Frame Window).
Sent before rendering is started. This notification is sent out before the renderer creates the render instance objects, which means that you can create nodes and other objects as a response to this event. When rendering multiple frames, this event is sent only once at the beginning of the rendering phase, and not on a per-frame basis. In the #preRender callback, you can't change any of the render parameters (height, width, aliasing, etc) and affect the current render sessions. Those parameters have already been set up internally in 3ds Max, and so changes to them won't occur until the next render session occurs.
Returns a 28 element array - see the SDK help file, class RendParams, for more information on the parameter definitions.
2 - Boolean - rpar -> isNetRender
3 - Boolean - rpar -> fieldRender
4 - Integer - rpar -> fieldOrder
6 - Boolean - rpar -> colorCheck
7 - Integer - rpar -> vidCorrectMethod
9 - Boolean - rpar -> superBlack
10 - Integer - rpar -> sbThresh
11 - Boolean - rpar -> rendHidden
12 - Boolean - rpar -> force2Side
13 - Boolean - rpar -> inMtlEdit
14 - Float - rpar -> mtlEditTile
15 - Boolean - rpar -> mtlEditAA
16 - Boolean - rpar -> multiThread
17 - Boolean - rpar -> useEnvironAlpha
18 - Boolean - rpar -> dontAntialiasBG
19 - Boolean - rpar -> useDisplacement
20 - Boolean - rpar -> useRadiosity
21 - Boolean - rpar -> computeRadiosity
22 - TextureMap - rpar -> envMap
23 - Time - rpar -> firstFrame
24 - Integer - rpar -> scanBandHeight
25 - Integer - rpar -> extraFlags
26 - Point2 - rpar -> width, rpar -> height
27 - Boolean - rpar -> filterBG
28 - Boolean - rpar -> alphaOutOnAdditive
Sent after rendering has finished. This notification is sent out after the renderer destroys the render instance objects, which means that you can create nodes and other objects as a response to this event. When rendering multiple frames, this event is sent only once at the end of the rendering phase, and not on a per-frame basis.
Sent just before the renderer starts evaluating objects.
Returns the time being rendered
Sent just before each frame is rendered by the renderer. This notification is sent out after the renderer has taken a snapshot of the scene geometry. At the time of this call the scene cannot be modified. The renderer has already called GetRenderMesh() on all the object instances, and the materials and lights are already updated. If you don't modify anything that is rendered, then it is okay to use this callback. The current frame being rendered is set into the MAXScript currentTime context and system global, so any references to other scene object properties will automatically be resolved at the currently rendering frame's time. This notification is not sent out when the renderer is called to update the Material Editor sample spheres, only during output rendering.
Sent just after each frame is rendered by the renderer. The current frame being rendered is set into the MAXScript currentTime context and system global, so any references to other scene object properties will automatically be resolved at the currently rendering frame's time. This notification is not sent out when the renderer is called to update the Material Editor sample spheres, only during output rendering.
Returns a 22 element array - see the SDK help file, class RenderGlobalContext, for more information on the parameter definitions.
1 - Integer - rendParams -> projType
2 - Point2 - rendParams -> devWidth, rendParams -> devHeight
3 - Point2 - rendParams -> xscale, rendParams -> yscale
4 - Point2 - rendParams -> xc, rendParams- > yc
5 - Boolean - rendParams -> antialias
6 - Matrix3 - rendParams -> camToWorld
7 - Matrix3 - rendParams -> worldToCam
8 - Point2 - rendParams -> nearRange, rendParams -> farRange
9 - Float - rendParams -> devAspect
10 - Float - rendParams -> frameDur
11 - TextureMap - rendParams -> envMap
12 - Color - rendParams -> globalLightLevel
13 - Time - rendParams -> time
14 - Boolean - rendParams -> wireMode
15 - Float - rendParams -> wire_thick
16 - Boolean - rendParams -> force2Side
17 - Boolean - rendParams -> inMtlEdit
18 - Boolean - rendParams -> fieldRender
19 - Boolean - rendParams -> first_field
20 - Boolean - rendParams -> field_order
21 - Boolean - rendParams -> objMotBlur
22 - Integer - rendParams -> nBlurFrames
Sent before preparing Reflect and Refract Maps for rendering
Sent after render setup and immediately before the actual render begins
Sent before rendering Tonemapping image
Sent just before a file link attach.
Sent just after a file link attach.
Sent just before a file link bind.
Sent just after a file link bind.
Sent just before a file link detach.
Sent just after a file link detach.
Sent just before a file link reload.
Sent just after a file link reload.
Sent after all of the new objects for a reload have been created, but before any objects have been deleted.
Sent before a new file is opened.
Calling callbacks.notificationParam() returns an integer value of 2 if a render preset file is being opened, undefined otherwise.
Sent after a new file is opened successfully.
Calling callbacks.notificationParam() returns an integer value of 2 if a render preset file is being opened, undefined otherwise.
Sent before the file open process starts.
Calling callbacks.notificationParam() returns an array with two elements:
1 if doing a normal file load,
Element 2 is the scene file name being loaded.
Sent after the file open process has finished.
Calling callbacks.notificationParam() returns a String containing the file name.
Calling callbacks.notificationParam() returns a String containing the file name.
Sent before the save process has started.
Calling callbacks.notificationParam() returns a 2 element array:
1 if doing a normal file save,
Element 2 is the scene file name being saved.
Sent after the save process has finished.
Calling callbacks.notificationParam() returns the same 2-element array as #filePreSaveProcess - please see above for details.
Sent before an old version file is saved.
Sent after an old version file is saved.
Calling callbacks.notificationParam() returns an integer value of 1 if object or scene Xref merged, undefined otherwise.
Sent after a file is merged successfully.
Calling callbacks.notificationParam() returns an integer value of 1 if object or scene Xref merged, undefined otherwise.
Sent after the merge process has finished.
Sent before a file is imported.
Sent after a file is imported successfully.
Sent before a file is exported.
Loading XRef (typically surrounding Merge notices)
Loading XRef (typically surrounding Merge notices)
Loading XRef (typically surrounding Merge notices)
Calling callbacks.notificationParam() returns a layer ReferenceTarget.
Sent before layer deleted, callbacks.notificationParam() returns the layer.
Sent after node placed on new layer, callbacks.notificationParam() returns an array containing 3 elements - the node, the old layer and the new layer
Sent just before the current edit object is about to change in Modify panel.
Sent just after the current edit object changes in Modify panel.
Sent whenever the Modify panel opens on a new selection, either because the Modify panel was just selected or because a new selection is made in the scene. The notify occurs at a point just prior to panel redraw but after the selection has been established, so that callback functions can modify the panel state without it being overwritten.
Sent whenever the Modify panel changes the sub-object level. Calling callbacks.notificationParam() returns an array containing the new SO level number and the old SO level number. Available in 3ds Max 9 and higher.
Sent before a modifier is added to a node.
Calling callbacks.notificationParam() within the callback function will return a 2 element array containing the node and the modifier which was added.
Sent after a modifier is added to a node.
Calling callbacks.notificationParam() within the callback function will return a 2 element array containing the node and the modifier which was added.
Sent before a modifier is deleted from a node.
Calling callbacks.notificationParam() within the callback function will return a 2 element array containing the node and the modifier which was deleted.
Sent after a modifier is deleted from a node.
Calling callbacks.notificationParam() within the callback function will return a 2 element array containing the node and the modifier which was deleted.
Sent just before loading a material library.
Sent just after loading a material library.
Calling callbacks.notificationParam() within the callback function will return the MaterialLibrary loaded.
Sent just before saving a material library.
Sent just after saving a material library.
Sent just before merging a material library.
Called when a material reference is added.
Calling callbacks.notificationParam() within the callback function returns the Material.
Called when a material reference is deleted.
Calling callbacks.notificationParam() within the callback function returns the Material
Calling callbacks.notificationParam() within the callback function returns the node.
Sent after a node is cloned but before theHold.Accept(..).
Calling callbacks.notificationParam() within the callback function returns the node.
Sent just after a node is added to the scene.
Calling callbacks.notificationParam() within the callback function returns the node.
Calling callbacks.notificationParam() within the callback function returns the node.
Calling callbacks.notificationParam() within the callback function returns the node.
Calling callbacks.notificationParam() within the callback function returns the node.
Calling callbacks.notificationParam() within the callback function returns the node.
Sent when a new parent-child link is made. Calling callbacks.notificationParam() within the callback function returns the node.
Sent when a parent-child link is broken.
Calling callbacks.notificationParam() within the callback function returns the node.
Sent before a node is deleted.
Calling callbacks.notificationParam() within the callback function returns the node.
Sent just before a node gets a new material.
Calling callbacks.notificationParam() within the callback function returns the node.
Sent just after a node gets a new material.
Calling callbacks.notificationParam() within the callback function returns the node.
Sent if a scene node is renamed.
Calling callbacks.notificationParam() within the callback function returns a 2 element array containing the old and new node name as strings
Sent when a scene node name is set or changed.
Calling callbacks.notificationParam() within the callback function returns a 3 element array containing the old name, the new name, and the node.
Calling callbacks.notificationParam() within the callback function returns the array of nodes.
This notification was broken in versions prior to 3ds Max 2014.
The fixed version will be called for individual bones, so the return value will still be an array, but containing only one node per call.
The notification will be broadcast for all bone anim property changes except for InvalidateObjectTM() which also alters a flag in the bone's property, but that flag would be changed also when a child bone is altered. This could happen by simply moving nodes in the viewport, so this case is excluded to avoid an avalanche of notifications.
Calling callbacks.notificationParam() within the callback function returns the array of nodes.
This notification was broken in versions prior to 3ds Max 2014.
The fixed version will be called for individual bones, so the return value will still be an array, but containing only one node per call.
The notification will be broadcast for all bone anim property changes except for InvalidateObjectTM() which also alters a flag in the bone's property, but that flag would be changed also when a child bone is altered. This could happen by simply moving nodes in the viewport, so this case is excluded to avoid an avalanche of notifications.
Calling callbacks.notificationParam() within the callback function returns the array of nodes
Calling callbacks.notificationParam() within the callback function returns the array of nodes whose properties have been changed.
Sent before Advanced Lighting property changes.
Calling callbacks.notificationParam() within the callback function returns the array of nodes whose properties will be changed.
Sent after Advanced Lighting property changes.
Calling callbacks.notificationParam() within the callback function returns the array of nodes whose properties have been changed.
Sent before mental ray property changes.
Calling callbacks.notificationParam() within the callback function returns the array of nodes whose mental ray properties will be changed.
Sent after mental ray property changes.
Calling callbacks.notificationParam() within the callback function returns the array of nodes whose mental ray properties have been changed.
Calling callbacks.notificationParam() within the callback function returns the array of nodes.
Calling callbacks.notificationParam() within the callback function will return a 3 element array where the first element is an array of the original nodes, the second element is an array of the cloned nodes, and the third element is a name value of #copy , #instance , or #reference , reflecting the clone type.
Calling callbacks.notificationParam() within the callback function returns the array of nodes.
Calling callbacks.notificationParam() within the callback function returns the array of nodes.
Beginning of the mirror operation.
Calling callbacks.notificationParam() within the callback function returns the array of nodes.
Calling callbacks.notificationParam() within the callback function returns the array of nodes.
Sent just before selected nodes are deleted.
Calling callbacks.notificationParam() within the callback function returns the Array of nodes about to be deleted.
Sent just after selected nodes are deleted.
Sent when the software goes live.
Sent just before 3ds Max is reset.
Calling callbacks.notificationParam() within the callback function will return an integer value corresponding to the option selected in the New Scene dialog:
3 - Keep Objects and Hierarchy
Sent just after 3ds Max is reset.
System path has changed - Catalogs dir modified from the Configure Path dialog.
System path has changed - Catalogs dir modified from the Configure Path dialog.
Sent just before the software enters the shutdown process.
Sent just before the software finishes the shutdown process.
Some operations involving the MAXScript Listener and the 3ds Max UI will not be available when this callback is run because they have been shut down already. Non-UI related operations like writing to a file would be performed correctly though.
Sent whenever a plug-in is loaded.
Calling callbacks.notificationParam() within the callback function will return the String containing the name of the dll loaded
Sent when the Radiosity plugin has changed.
Sent when the Radiosity process has finished.
Sent when the Radiosity process has been reset.
Sent when the Radiosity process has started.
Sent after a scene undo is performed. callbacks.notificationParam() returns the name of the undo entry in 3ds Max 8 and higher.
Sent after a scene redo is performed. callbacks.notificationParam() returns the name of the undo entry 3ds Max 8 and higher.
Sent when the Schematic View selection set has changed. callbacks.notificationParam() returns the Schematic View index.
Sent when the user double-clicked a Schematic View node.
Sent before Schematic View applies its layout algorithm.
Calling callbacks.notificationParam() within the callback function returns the Schematic View index.
Sent after Schematic View applies its layout algorithm.
Calling callbacks.notificationParam() within the callback function returns the Schematic View index.
Sent whenever a URL is loaded into the Asset Browser.
Calling callbacks.notificationParam() within the callback function returns the String containing the URL to browse to.
Sent after a named selection set is created.
Calling callbacks.notificationParam() will return the new selection set name.
Available in 3ds Max 9 and higher.
Sent after a named selection set is deleted.
Calling callbacks.notificationParam() will return the name of the deleted named selections set.
Available in 3ds Max 9 and higher.
Sent after a named selection set is renamed.
Calling callbacks.notificationParam() will return an array containing the old name and new name of the renamed selection set.
Sent before the DirectX device is being reset.
Available in 3ds Max 9 and higher.
Sent after the DirectX device has been reset.
Sent after a bitmap is reloaded.
Calling callbacks.notificationParam() within the callback function returns the String containing bitmap texture bitmap file name.
Sent AFTER object categories marked to be hidden\unhidden.
Sent when the system is updating it’s custom colors.
Sent AFTER custom display filters have been activated\deactivated.
Sent when lighting unit display system is changed.
Sent if the user changes the reference coordinate system.
Sent if the user changes the time format setting.
Sent if the user changes the unit setting.
Sent every time the viewport parameters change, including panning, zooming and orbiting the viewport or changing the active viewport.
Currently, there is no notification for viewport layout change.
#viewportSafeFrameToggle: integer
Sent when the viewport Safe Frame is turned on or off.
Calling callbacks.notificationParam() within in the callback function returns an Integer value - 1 for on, 0 for off.
Available in 3ds Max 2014 and higher.
Sent when the main application window gets enabled.
Calling callbacks.notificationParam() within the callback function returns a Boolean value - true if the main 3ds Max window is being enabled, false if another window is being enabled.
Sent when a user operated the height menu.
Sent before the progress bar is displayed.
Sent after the progress bar is finished.