If other applications are working with any AutoCAD objects at the same time as your program, those objects might not be accessible. This is especially important to look out for if your application includes reactors, because reactors execute code segments in response to external events that cannot be predicted in advance.
Visual LISP provides the following functions to test the accessibility of an object before trying to use the object:
These functions return T if true, nil if false. The following examples test a line object:
Determine whether the line is readable:
(vlax-read-enabled-p WhatsMyLine) T
Determine whether the line is modifiable:
(vlax-write-enabled-p WhatsMyLine) T
Determine if the line has been erased:
(vlax-erased-p WhatsMyLine) nil
Erase the object assigned WhatsMyLine:
(vla-delete WhatsMyLine) nil
Check to see if WhatsMyLine is still readable:
(vlax-read-enabled-p WhatsMyLine) nil
Confirm the object was deleted:
(vlax-erased-p WhatsMyLine) T