Handling Deleted Wrapped Objects
 
 
 

There is a potential in MAXScript for a wrapper value to reference a deleted MAX object. This might happen, for example, if a 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() 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::ref_deleted which holds a BOOL.

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