Document object |
An AutoCAD drawing.
VBA class name: |
AcadDocument |
---|---|
Create using: |
Documents.Add |
Access via: |
Documents.Item |
The active document (AutoCAD drawing) can be accessed using ThisDrawing in VBA, or through the ActiveDocument property in VB. Because AutoCAD works with only one document at a time, and that document represents one database, the active document can be thought of as the current database as well as the current document.
Certain objects in the drawing establish the format, location, or style that new objects being added to the drawing will adopt. These objects include the DimensionStyle, TextStyle, Linetype, Viewport, and Layer objects. A drawing may contain many of these types of objects, but only one may be active at a time. For example, there may be several linetypes available in a drawing, but only one, designated as the active one, will be used when creating a new entity. The Document object contains the references to these active objects. To set an existing object as the active object, use the properties listed below.
The Document object also contains a property (or link) for all the collections. From these collections, you can iterate through every object in the drawing.
To access drawing properties such as Title, Subject, Author, and Keywords, the IAcadSummaryInfo interface, accessible as a property of the Document object, must be used.
Using Paper Space and Model Space
From the Document object, you control the model space and paper space settings. By default, a drawing is opened in the model space, with the tiled viewport setting. Use the ActiveSpace property, MSpace property, and the Display method to control the model space and paper space settings. See the PViewport object for more information about using these properties and methods.
Resetting Active Objects
Changes to most active objects, such as the active layer and active linetype, are displayed immediately. However, several objects must be reset for changes to appear. These objects are the active textstyle, active UCS, and the active viewport. To reset the objects, simply call the ActiveTextStyle, ActiveUCS, or ActiveViewport property, using the updated object.
To create or open a Document object, use the Open method. To edit or query a Document object, use the following methods and properties:
Methods |
Properties |
Events |
Comments? |