Evaluating a Graph

When you evaluate the graph (Build Evaluate or Ctrl+E), then the computation you have coded (the new geometry, modifier, or utility plug-in, or the MAXScript function) becomes available in the 3ds Max interface.

Evaluating a Max Creation Graph

At evaluation time, the following things happen:

  1. The graph is saved (a .maxtool file).

    This is the XML encoding of the visual graph.

  2. The graph is validated.
  3. The compounds are expanded in line.
  4. Types are inferred and validated for all generic types.
  5. Byte-code is generated.

    This is the binary .NET expression tree.

  6. A representation of the expression tree (a .txt file) is created.
  7. A MAXScript wrapper (.ms file) is created.
  8. The MAXScript file is evaluated.

Dynamic Compilation and Text Representations of Compiled Graphs

Graphs are compiled as needed into .NET byte-code via the .NET expression tree API. The .NET run-time in turn compiles .NET byte-code into native assembly code. The text representation of a graph is stored in the same folder as the graph with the same base file name and the extension .txt.

The text representation of a compiled graph is pseudocode that resembles C#. One of the major differences is that both statements and blocks of code are expressions. A block of code has the value equal to the last statement in the block. There are no return statements in the pseudocode.

MAXScript Wrapper

The main purpose of the MAXScript file generated from a Max Creation Graph is to register a plug-in with 3ds Max that bridges the gap between 3ds Max and the dynamically created function.

The auto-generated plug-in from an MCG tool can be used in the same way as any other plug-in: It has parameters that can be scripted, it generates a rollout, it can be saved in the scene, changes to parameters are undoable, there is a class-ID, and so on.

Important: If you distribute the MAXScript file alone without an MCG graph file (the .maxtool file) it will not work: MAXScript uses the MCG engine to dynamically compile the graph file on initialization.