MAXScript Functions
 
 
 

MAXScript functions are represented using the class MAXScriptFunction defined in the header file maxscrpt\funcs.h. If you have an instance of MAXScriptFunction you can use the following method to evaluate the function:

Value* MAXScriptFunction::apply(Value** arglist, int count, CallContext* cc=NULL)

Functions exposed to the MAXScript engine using the function publishing system are represented as instances of the class InterfaceFunction.

All MAXScript functions are derived from the Value class, meaning that they first class values in MAXScript.

Primitive Functions

The most important kind of 3ds Max function is the Primitive function of which there are three kinds:

The function argument to these macros must have the following signature:

Value* <name>_cf(Value** arg_list, int count)

To avoid name conflicts the C++ function implementation must have the suffix "_cf". The name argument to the macro is used to define a global MAXScript variable with the given name. This global variable will hold the function.

Type and Argument Checking

There is no implicit type or argument checking in this calling mechanism - you have to do it yourself in the C++ implementation function. The following macros to help with this:

Example:

Value* open_file_cf(Value** arg_list, int count)
{
  // check that we have 1 arg and that it's a string
  check_arg_count(openFile, 1, count);
  type_check(arg_list[0], String, "openFile filename");
  ...
  char* fn = arg_list[0]->to_string();
  ...
}