If other applications are working with any AutoCAD objects at the same time as your program, those objects may 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 (see Attaching Reactors to AutoCAD Drawings). Even a simple thing such as a locked layer can prevent you from changing an object's properties.
VLISP provides the following functions to test the accessibility of an object before trying to use the object:
- vlax-read-enabled-p tests whether you can read an object.
- vlax-write-enabled-p determines whether you can modify an object's properties.
- vlax-erased-p checks to see if an object has been erased. Erased objects may still exist in the drawing database.
These test 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
See if the line has been erased:
$ (vlax-erased-p WhatsMyLine)
nil
_$ (vla-delete WhatsMyLine)
nil
Issue vlax-read-enabled-p to see if WhatsMyLine is still readable:
$ (vlax-read-enabled-p WhatsMyLine)
nil
Issue vlax-erased-p again to confirm the object was deleted:
$ (vlax-erased-p WhatsMyLine)
T