Handling Deleted Objects (SDK)

3DS Max Plug-In SDK

Handling Deleted Objects (SDK)

There is a potential in MAXScript for a wrapper value to reference a deleted MAX object. This might happen, for example, if a MAX global variable contains a MAXNode value and the user interactively deletes the object that the MAXNode references. It is critical for any code that works with wrapper values to first check to make sure the wrapped MAX objects are not deleted using the macro:

deletion_check(val);

which takes a MAXWrapper derived class instance. This macro will throw an appropriate runtime error if the MAX object referenced by 'val' is deleted. If you want to handle the error reporting yourself or perform some conditional code, you can test the MAXWrapper public data member, ref_deleted, which holds a C++ BOOL.

You typically only need to do this checking once on entry to your code because scripts always run synchronously - MAXScript locks out the MAX UI so users cannot do things to the scene that would potentially crash a running script.