The AnimHandle system defines a unique ID number for every entity in the scene, including nodes, modifiers, materials, controllers, etc. When an entity is deleted from memory, its number will never be reused by any entity created later, except in the case of the so-called "wrap-around" - an unhealthy condition possible only when four billion entities (the 32-bit limit) are created in a single 3ds Max session.
Therefore you can determine whether an object is deleted by requesting the object using its handle, and seeing if the result is undefined.
Available in 3ds Max 2008 and higher.
Methods:
<integer>GetHandleByAnim <object>
This method returns the unique AnimHandle ID for the given scene entity.
<object>GetAnimByHandle <integer>
This method returns the scene entity corresponding to the unique AnimHandle ID, or undefined if the entity has been deleted or has not been created yet.
<IntegerPtr>getAnimPointer <maxwrapper>
This method returns a pointer to the wrapped refTarg as an IntegerPtr, or 0 if the value is undefined
.
<maxwrapper>getAnimByPointer <IntegerPtr>
Returns the corresponding maxwrapper for the specified pointer address. This means: (getAnimByPointer (getAnimPointer <maxwrapper>)) == maxwrapper
. This function is intended mainly for internal use and debugging.
Available in 3ds Max 2018 and higher.
FOR EXAMPLE:
x = teapot() --create a teapot xHandle = GetHandleByAnim x --get the anim.handle x_verify = GetAnimByHandle xhandle --get by anim.handle x == x_verify --compare the two -returns true delete x --delete the teapot clearUndoBuffer() --object deleted completely from memory x_verify = GetAnimByHandle xhandle --now returns undefined