Structure Creation and Cloning Event Handlers

In 3ds Max 2010 and higher, two event handlers can be implemented in struct definitions to be called on struct creation and struct cloning.

The struct event handlers are always private.

These event handlers can be used to perform additional initialization tasks, print out the initial values of variables for debugging purposes, and so on.

   

Syntax:

on create do <expression>

This handler is called when an instance of the struct is created.

   

on clone do <expression>

This handler is called when a copy of a struct instance is created.

EXAMPLE- DEFINITION AND CREATION:

struct foo2
(
A = 1,
B = 3,
fn error = throw "ZZZ",
on create do format "Struct Created: %\n" this,
on clone do format "Struct Cloned: %\n" this
)
 
f = foo2 ()

RESULT:

#Struct:foo2(
a:<data>; Public,
b:<data>; Public,
error:<fn>; Public)
Struct Created: (foo2 a:1 b:3)
(foo2 a:1 b:3)

CONTINUED EXAMPLE - CLONING:

f2 = copy f

RESULT:

Struct Cloned: (foo2 a:1 b:3)
(foo2 a:1 b:3)

See Also