About Accessing the Current Document Object (AutoLISP/ActiveX)


The AutoCAD object model hierarchy starts at the Application object, and from there you can use the ActiveDocument property to access the Document object that represents the active drawing.

NoteActiveX support in AutoLISP is limited to Windows only.

The Documents collection can also be accessed so you can step through each open drawing. The following AutoLISP statement returns the active document:

(setq acadDocument (vla-get-ActiveDocument (vlax-get-acad-object)))

The Document object has many properties that allow you to access non-graphical objects (layers, linetypes, and groups, for example) through like-named properties such as Layers, Linetypes, and Groups. Access to the graphical objects in a drawing are provided with the ModelSpace (model space) and PaperSpace (paper space) properties. The ActiveSpace property can be used to determine if model or paper space are current in the drawing.

For example:

(setq mSpace (vla-get-ModelSpace acadDocument))

At this point, you can add objects to the drawing’s model space.

For example, you can add a circle to the model space with the following statement:

(setq mycircle (vla-addCircle mSpace (vlax-3d-point '(3.0 3.0 0.0)) 2.0))