CadDocuments
from OpenCAD2D import CadDocuments
class CadDocuments(System.Object) ยท CadDocuments in the .NET reference
The drawings open in the app, as AutoCAD's DocumentManager holds the documents of a session: listed, one made active, one opened, a new one made from the template, one closed with or without its changes saved. A plugin reaches it as CadPluginContext.Documents or CadCommandContext.Documents. Every call does what the user's action or a Remote call does, through the window's own code: CadDocuments.Open is File > Open, a drawing opened already is shown, not read twice; CadDocuments.Add is QNEW; CadDocuments.Active set is a click on the drawing's row of the DRAWINGS list; the close calls are the x of a row once the question is answered.
Properties and fields
Active
@property
def Active(self) -> CadDocument | None
@Active.setter
def Active(self, value: CadDocument) -> None
Gets or sets the drawing the user works in, null where none is open: AutoCAD's MdiActiveDocument. Setting it shows another drawing open, as clicking its row of the DRAWINGS list does; the drawing already shown is left as it is.
Count
@property
def Count(self) -> int
Gets the number of drawings open: 2 for a window with A-101.dwg and B-202.dwg open.
HasWindow
@property
def HasWindow(self) -> bool
Gets whether the app's window holds the drawings: false in a test and in the Remote test server, where the list is the session's own drawing and the calls that change what is open say there is no window.
Methods
Add
def Add(self, template: str | None = ...) -> CadDocument
Starts a new drawing and shows it, as QNEW does: from the template, named Drawing1.dwg and then on, with no file of its own until it is saved.
Close
def Close(self, document: CadDocument) -> None
Closes a drawing that has no changes unsaved, as the x of its row does: it leaves the list, and the next drawing is shown, or the start screen where it was the last. Nothing is asked and nothing is saved.
CloseAndDiscard
def CloseAndDiscard(self, document: CadDocument) -> None
Closes a drawing and throws away its changes not saved, as the x of its row does once the question is answered Don't save.
CloseAndSave
def CloseAndSave(self, document: CadDocument) -> None
Saves a drawing to its file, as Ctrl+S does, then closes it. A drawing that cannot be closed is not saved.
GetEnumerator
def GetEnumerator(self) -> System.Collections.Generic.IEnumerator[CadDocument]
Gets an enumerator over the drawings open, in the order of the list; the list does not change under it.
Open
def Open(self, path: str) -> CadDocument
Opens a DWG or DXF file and shows it, or shows it where it is open already, as File > Open does with the file read at once. Each extension is told of the drawing and the line "Opened plan.dxf: 12 entities, 3 layers." goes to the command line.
Operators and Python protocols
__getitem__
def __getitem__(self, index: int) -> CadDocument
Gets a drawing open by its place in the list, which is ordered by file name.
__iter__
def __iter__(self) -> Iterator[CadDocument]
__len__
def __len__(self) -> int