Share

Customizing an MCG Tool with MAXScript

Tools built with MCG are scripted plug-ins, just like any other. You can customize and extend a tool by adding MAXScript to its Custom UI property. This allows your MCG tool do anything that a scripted plug-in can do.

The contents of the Custom UI property get inserted automatically into the tool definition every time the graph is evaluated (compiled). The contents are inserted after most of the generated code for defining local variables, defining the graph's parameter block, and handling events, but before the main update handlers that evaluate a plug-in instance and update the scene.

This allows you to override much of the generated code by redefining portions of it in the Custom UI property. The definitions that occur later in the plug-in file replace the earlier ones. For example, you can extend the existing event handlers, as well as define new event handlers (such as for mouse actions), add parameter blocks, and more.

Almost all of the generated MAXScript can be overridden. The exceptions are the main evaluation handlers for the different graph types:

  • buildMesh for geometry operators
  • modifyMesh for modifiers
  • getValue for controllers

However, you can modify your tool to run custom MAXScript when these events occur by defining PreInvokeMethod and PostInvokeMethod functions. The main evaluation handlers call these functions if they have been defined.

Note that the default rollout gets generated automatically only if the Custom UI property is empty. If you are using MAXScript in the Custom UI property to extend an MCG tool, then you must either define a custom rollout of your own, or restore the default rollout.

Was this information helpful?