CadDocument
from OpenCAD2D import CadDocument
class CadDocument(System.Object) · CadDocument in the .NET reference
A drawing open in the presenter: a DxfDatabase with its spaces, the display list of each, the index that picks in it and the selection. Opening and showing run with no window, so a test can drive them.
The handles AutoCAD gives the entities of a drawing that writes none, on opening it.
A viewport of a layout maximized into a temporary model view, as AutoCAD 2021's VPMAX does it and VPMIN takes it back.
The tiled viewports model space is shown through.
Model space worked in through a viewport of a layout, as AutoCAD's MSPACE: the layout is still the one shown, but picks, snaps and commands work in model space as the viewport shows it, and zooming changes the viewport's view.
The authoring edits of the Block Editor, as AutoCAD 2021's: the visibility states of the block open (BVSTATE) and the objects they show (BVHIDE, BVSHOW), and the parameters and actions taken out of it. Each is an edit of the document, one undo step of its own or a part of the command's that makes it; the work on the evaluation graph is the library's (DxfBlockVisibility, DxfBlockAuthoring).
The Block Editor, as AutoCAD 2021's BEDIT: a block of the drawing (or model space itself, as <Current Drawing>) shown alone in a space of its own, where every drawing and modify command works on the block's entities.
The editing half of the document: every change goes through CadDocument.ApplyEdit, one undo step each (or one for a group of them, as a command makes), with undo, redo, saving and the CadDocument.Changed event.
The layer filter the drawing looks through: the one chosen in the Layer manager's tree, whether it is inverted, and whether the layer box of the ribbon lists only the layers it lets through (AutoCAD's Apply layer filter to layer toolbar).
The history LAYERP reads (Layer Previous): before each change or set of changes to the settings of layers, the settings the layers had are kept, so that LAYERP puts them back without touching any other edit. A set is what one command does (LAYISO turning off nine layers and moving the current one is one), what one Layer manager session does (CadDocument.BeginLayerSet), or one change made on its own, as the layer box makes one. Only the layers the set changed are kept, with the settings they had.
The switch from one space to another, model space or a layout, and MSPACE and PSPACE, as undo steps.
The object inside a block reference that a point reaches, which LAYOFF and LAYFRZ take the layer of by their Block selection setting.
In-place editing of a block reference, as AutoCAD 2021's REFEDIT: the objects of the reference's block copied into the drawing where the reference draws them (the working set), edited there with every command, REFSET adding objects to the set and taking them out, REFCLOSE writing them back into the block or discarding them. The other objects of the drawing are locked while it lasts and faded.
How objects are picked in the document: groups taken whole (PICKSTYLE), overlapping objects cycled through (SELECTIONCYCLING), and objects selected before a command taken by it (PICKFIRST).
Settings kept in the drawing and changed in place, as the snap and grid of a viewport, as undo steps. A setting is a handful of values in the drawing, and putting it back by those values is what its step does: the step shares the drawing kept before it, so that no copy of the drawing is saved for it and an undo or a redo of it reads nothing again, in a drawing of a million entities too (see CadDocument.ApplySetting).
The snapshot and reset of a drawing in memory: one call keeps the drawing as it stands, another puts it back, as often as wanted, for a program that runs episodes of edits from the same start.
The clocks of the drawing TIME shows (CadDocumentTimes).
UNDO's own settings and its groups: Control (All, None, One), Auto, Combine and Layer, and BEgin and End, which make the commands between them one step of U and REDO under the name GROUP.
The views of model space and of the paper of a layout as undo steps and as ZOOM Previous entries. A viewport's view is a property of the viewport in the drawing and is undone with the drawing; the view of a space is not in the drawing, so the step of a zoom or a pan of a space holds the part of the space shown before and after, and undoing it moves the view and reads nothing again.
The fonts a document's text is drawn in.
The hatch settings of a document: those HATCH makes the next hatch with, and those of the hatch HATCHEDIT changes.
The folders a document's support files are looked for in.
The folder a document's plot style tables are read from.
The user coordinate systems of the drawing.
The external references and images of a document.
Properties and fields
ActiveViewport
@property
def ActiveViewport(self) -> DxfViewport | None
Gets the viewport of the layout shown whose model space is worked in (MSPACE), as AutoCAD's current viewport; null on the paper (PSPACE), in model space, and where that viewport has been erased or switched off since.
AnnoAutoScale
@property
def AnnoAutoScale(self) -> int
@AnnoAutoScale.setter
def AnnoAutoScale(self, value: int) -> None
Gets or sets ANNOAUTOSCALE, as AutoCAD's: whether the annotative objects of model space are shown at the scale CANNOSCALE is changed to, which they are given as OBJECTSCALE gives it. Positive switches it on, negative off, and the size says which objects (probed on AutoCAD 2021, texts on layers that are on, locked, frozen and off): 1 those on layers that are on, thawed and not locked, 2 those on layers that are on and thawed (locked too), 3 those on layers that are not locked (off or frozen too), 4 all of them. -4, the default, adds nothing. Kept by the presenter, not in the drawing, as AutoCAD keeps it in the registry; the variable ANNOAUTOSCALE sets it.
ApplyLayerFilterToToolbar
@property
def ApplyLayerFilterToToolbar(self) -> bool
@ApplyLayerFilterToToolbar.setter
def ApplyLayerFilterToToolbar(self, value: bool) -> None
Gets or sets whether the layer box lists only the layers the filter lets through, the current layer always among them.
BlockEditor
@property
def BlockEditor(self) -> CadBlockEditor | None
Gets the Block Editor open on this drawing; null where none is.
CanRedo
@property
def CanRedo(self) -> bool
Gets whether there is a step to redo; false while a command's group of edits is open, and while UNDO Control None is on, which keeps no steps to put again (AutoCAD 2021: "REDO command disabled. Use UNDO C to turn it on."). Under One the step just undone can be put again, as AutoCAD 2021 does; a redo list made before One was set is forgotten.
CanUndo
@property
def CanUndo(self) -> bool
Gets whether there is a step to undo; false while a command's group of edits is open, and while UNDO Control None has the undo list turned off.
ConstraintBars
@property
def ConstraintBars(self) -> CadConstraintBars
Gets the constraint bars of the document: which are shown, and the icons of each.
CurrentSpace
@property
def CurrentSpace(self) -> CadSpace
@CurrentSpace.setter
def CurrentSpace(self, value: CadSpace | None) -> None
Gets or sets the space the canvas shows; see CadDocument.WorkingSpace for the one edits go into.
Database
@property
def Database(self) -> DxfDatabase
Gets the drawing.
DefaultLineWeight
@property
def DefaultLineWeight(self) -> float
@DefaultLineWeight.setter
def DefaultLineWeight(self, value: float) -> None
Gets or sets the width, in millimetres, a lineweight of Default is drawn with when a space is next drawn, as AutoCAD's LWDEFAULT: 0.25 until set. A display list already made keeps its widths until CadDocument.Regen.
EditGate
@property
def EditGate(self) -> ICadEditGate
@EditGate.setter
def EditGate(self, value: ICadEditGate | None) -> None
Gets or sets the gate every planned change of an existing entity is asked through before it is written (see ICadEditGate); the gate of the document's CadDocument.Owners (CadOwnerEditGate) until another is given, and again when set to null. With no owner registered it lets every edit through.
EnterableViewports
@property
def EnterableViewports(self) -> System.Collections.Generic.IReadOnlyList[DxfViewport]
Gets the viewports of the layout shown that can be worked through, in the order the layout holds them, as Ctrl+R cycles them; empty in model space.
EntityCount
@property
def EntityCount(self) -> int
Gets the number of entities in model space, as the file list shows it ("DXF · 412 entities"): counted when first asked and again after the drawing next changes (an edit, an undo, a redo, a regen).
FieldDisplay
@property
def FieldDisplay(self) -> bool
Gets whether the words of a field are drawn on a grey ground that is not plotted, as AutoCAD's FIELDDISPLAY 1 does; true until FIELDDISPLAY is set to 0.
FileName
@property
def FileName(self) -> str | None
Gets the full path of the file it was opened from, or the name it was given; null for neither.
Fonts
@property
def Fonts(self) -> CadFonts
@Fonts.setter
def Fonts(self, value: CadFonts) -> None
Gets or sets the fonts the text is drawn in: off until set, every style then drawn as the canvas draws it, an SHX font in the canvas's own font. Set to fonts other than those it has, every space is drawn again, as REGEN does, and the fonts missing are said again; fonts set as the same are kept, so that a font not found is not said again. The words of a dimension in an SHX font are measured, as its picture is laid out, in the fonts of the document the dimension is in, and in no other document's; a TrueType font is measured from the Fonts folder of Windows whatever the fonts.
HasFile
@property
def HasFile(self) -> bool
Gets whether the drawing has a file of its own to CadDocument.Save to: it was opened from one or saved as one.
HatchBeingEdited
@property
def HatchBeingEdited(self) -> CadHatchSettings | None
@HatchBeingEdited.setter
def HatchBeingEdited(self, value: CadHatchSettings | None) -> None
Gets or sets the settings of the hatch HATCHEDIT is changing while it asks the window for its dialog: read from the hatch before, applied by HATCHEDIT after, unless the window sets them to null, as Cancel does. Null at any other time.
HatchSettings
@property
def HatchSettings(self) -> CadHatchSettings
@HatchSettings.setter
def HatchSettings(self, value: CadHatchSettings) -> None
Gets or sets the settings HATCH makes the next hatch with, as AutoCAD keeps HPNAME, HPANG, HPSCALE and the rest for the drawing while it is open: ANSI31 at angle nought and scale 1 until set; the Hatch settings dialog sets them.
InvertLayerFilter
@property
def InvertLayerFilter(self) -> bool
@InvertLayerFilter.setter
def InvertLayerFilter(self, value: bool) -> None
Gets or sets whether the layers the filter lets through are left out and the others listed, as the Layer manager's Invert filter does.
IsInGroup
@property
def IsInGroup(self) -> bool
Gets whether a group of edits is open, as while a command runs.
IsModified
@property
def IsModified(self) -> bool
Gets whether the drawing differs from the one opened or last saved, as the title's * shows; a user coordinate system changed counts, as in AutoCAD.
IsViewportMaximized
@property
def IsViewportMaximized(self) -> bool
Gets whether a viewport of the layout shown is maximized (CadDocument.MaximizedViewportHandle).
LayerFilterPath
@property
def LayerFilterPath(self) -> System.Collections.Generic.IReadOnlyList[str]
@LayerFilterPath.setter
def LayerFilterPath(self, value: System.Collections.Generic.IReadOnlyList[str] | None) -> None
Gets or sets the names, from the top, of the filter the Layer manager lists the layers of: Steel, Beams for the filter Beams nested in Steel; the name of one of the three AutoCAD makes (All Used Layers); empty for All. Read from the filter the drawing marks as current (group 290 of its XRECORD) until first set.
LayerPreviousMode
@property
def LayerPreviousMode(self) -> bool
@LayerPreviousMode.setter
def LayerPreviousMode(self, value: bool) -> None
Gets or sets whether changes to layers are kept for LAYERP: on by default, as AutoCAD's LAYERPMODE 1. Turned off, what is changed is not kept and LAYERP says it is disabled; what was kept stays until LAYERP takes it.
Layers
@property
def Layers(self) -> System.Collections.Generic.IReadOnlyList[CadLayerInfo]
Gets the layers of the drawing.
LeftOutOfDwg
@property
def LeftOutOfDwg(self) -> str
Gets what the last save as a DWG left out of the file, the types of record the DWG writer does not write yet, each with how many, in ordinal order: "IMAGE 1" for a drawing with one picture attached. Empty where nothing was, or the drawing was last saved as a DXF or not at all.
LeftOutOfDxf
@property
def LeftOutOfDxf(self) -> System.Collections.Generic.IReadOnlyList[str]
Gets what the last save as a DXF of another version could not write, a sentence each: the kinds of record left out and those written another way, as DxfDatabase.Save says them. Empty where nothing was, or the drawing was last saved as a DWG or in its own version.
MaximizedViewportHandle
@property
def MaximizedViewportHandle(self) -> str | None
Gets the handle of the viewport of the layout shown that VPMAX has maximized and VPMIN has not yet taken back; null where none is, and where an undo has taken the maximizing back.
ModelSpace
@property
def ModelSpace(self) -> CadSpace
Gets model space.
NextRedo
@property
def NextRedo(self) -> CadUndoStep | None
Gets the step CadDocument.Redo would redo, or null.
NextUndo
@property
def NextUndo(self) -> CadUndoStep | None
Gets the step CadDocument.Undo would undo, or null.
OleFrame
@property
def OleFrame(self) -> int
@OleFrame.setter
def OleFrame(self, value: int) -> None
Gets or sets whether the frames of OLE objects are drawn and plotted, as AutoCAD's OLEFRAME: 0 for no frame, 1 for frames shown and plotted, 2, the default, for frames shown and left off a plot. AutoCAD saves it in the drawing; a DXF has no place for it, so it lasts as long as the document is open. A display list already made keeps its frames until CadDocument.Regen.
OleHide
@property
def OleHide(self) -> int
@OleHide.setter
def OleHide(self, value: int) -> None
Gets or sets which OLE objects are shown and plotted, as AutoCAD's OLEHIDE: 0, the default, those of both spaces, 1 those of paper space only, 2 those of model space only, 3 none. AutoCAD keeps it in the registry; here it lasts as long as the document is open. A display list already made keeps its objects until CadDocument.Regen.
OleQuality
@property
def OleQuality(self) -> int
@OleQuality.setter
def OleQuality(self, value: int) -> None
Gets or sets the plot quality new OLE objects take, as AutoCAD's OLEQUALITY: 0 monochrome, 1 low graphics, 2 high graphics, 3, the default, by the kind of object, which for a picture is high graphics. AutoCAD keeps it in the registry; here it lasts as long as the document is open.
Owners
@property
def Owners(self) -> CadOwnerRegistry
Gets the owners registered with this document: the code that owns entities it wrote (a model drawing, for one) and says how each may be edited.
PdfFrame
@property
def PdfFrame(self) -> int
@PdfFrame.setter
def PdfFrame(self, value: int) -> None
Gets or sets whether the frames of PDF underlays are drawn and plotted, as AutoCAD's PDFFRAME: 0 for no frame, 1, the default, for frames shown and plotted, 2 for frames shown and left off a plot. AutoCAD saves it in the drawing; a DXF has no place for it, so it lasts as long as the document is open. A display list already made keeps its frames until CadDocument.Regen.
PdfOsnap
@property
def PdfOsnap(self) -> bool
@PdfOsnap.setter
def PdfOsnap(self, value: bool) -> None
Gets or sets whether object snaps find the geometry of PDF underlays, as AutoCAD's PDFOSNAP: true, the default, where the snaps End, Mid, Cen, Int and the others take the lines and curves a PDF draws, false where they pass over them. It lasts as long as the document is open.
PickAdd
@property
def PickAdd(self) -> int
@PickAdd.setter
def PickAdd(self, value: int) -> None
Gets or sets PICKADD, as AutoCAD's: 1 (the default) and 2 add each object picked, or taken by a window, to those selected, Shift taking it out; 0 makes what is picked last the selection, Shift adding to it. So with 0, a click on line A and then on line B leaves B alone selected, and a click on B with Shift held leaves both. AutoCAD's 2 keeps what its SELECT command took selected after it, which the presenter, with no SELECT, takes as 1. Kept by the presenter, not in the drawing, as AutoCAD keeps it in the registry; the variable PICKADD sets it.
PickFirst
@property
def PickFirst(self) -> int
@PickFirst.setter
def PickFirst(self, value: int) -> None
Gets or sets PICKFIRST, as AutoCAD's: 1 (the default) lets a command that works on objects (MOVE, ERASE) take those selected before it started; 0 makes it ask "Select objects:" whatever is selected. Kept by the presenter, not in the drawing, as AutoCAD keeps it in the registry; the variable PICKFIRST sets it.
PickStyle
@property
def PickStyle(self) -> int
@PickStyle.setter
def PickStyle(self, value: int) -> None
Gets or sets PICKSTYLE, as AutoCAD's: 1 (the default) picks a selectable group whole when one of its objects is picked, 0 picks the object alone; 2 and 3 are AutoCAD's associative hatch selection, which the presenter takes as 0 and 1. Ctrl+Shift+A switches between 0 and 1. Kept by the presenter, not in the drawing, as AutoCAD keeps it in the registry.
PlotStyleFolder
@property
def PlotStyleFolder(self) -> str
@PlotStyleFolder.setter
def PlotStyleFolder(self, value: str | None) -> None
Gets or sets the folder the plot style tables a plot names (CadPlotSettings.StyleSheet) are read from, as CadPlotStyleFolder lists them: empty, the default, for no folder, when the tables the presenter makes (CadPlotStyleFolder.BuiltIn) stand in and nothing is read from disk. The window sets Global settings' plot style folder, CadPlotStyleFolder.DefaultPath where that is empty.
PointViewHeight
@property
def PointViewHeight(self) -> float
@PointViewHeight.setter
def PointViewHeight(self, value: float) -> None
Gets or sets the height of the view, in drawing units, that sizes the points of a relative size (PDSIZE nought or below) when a space is next drawn, as AutoCAD sizes them by the viewport at a regeneration: with PDSIZE -10 and a view 300 high, each point's symbol is 30 across. A display list already made keeps its sizes until CadDocument.Regen; REGEN sets it from the view of its command line first. Nought, the default, takes the height of the drawing's extents, else of its limits.
RefEdit
@property
def RefEdit(self) -> CadRefEdit | None
Gets the in-place edit open on this drawing (REFEDIT); null where none is.
RefEditAttributeDefinitions
@property
def RefEditAttributeDefinitions(self) -> bool
@RefEditAttributeDefinitions.setter
def RefEditAttributeDefinitions(self, value: bool) -> None
Gets or sets whether REFEDIT brings the attribute definitions of the block into the working set, as the Reference Edit dialog's "Display attribute definitions for editing" does; false, the default, leaves them in the block.
RefEditLocksObjects
@property
def RefEditLocksObjects(self) -> bool
@RefEditLocksObjects.setter
def RefEditLocksObjects(self, value: bool) -> None
Gets or sets whether REFEDIT locks the objects outside the working set, as the Reference Edit dialog's "Lock objects not in working set" does; true by default. A session keeps the setting it opened with.
RefEditUniqueNames
@property
def RefEditUniqueNames(self) -> bool
@RefEditUniqueNames.setter
def RefEditUniqueNames(self, value: bool) -> None
Gets or sets whether REFEDIT of an external reference gives the layers of the working set names of their own, as the Reference Edit dialog's "Enable unique layer and symbol names" does; true by default. On, the layer WALL of the reference's drawing is the layer $0$WALL in this drawing while the edit lasts (the number raised past a name this drawing has), a copy of it no layer of this drawing can clash with, and goes back to WALL in the file when saved; off, it stays WALL and shares the layer of this drawing of that name, if there is one. A session keeps the setting it opened with; the edit of a block, whose objects stand on this drawing's own layers, is not changed by it.
RevCloudGrips
@property
def RevCloudGrips(self) -> bool
@RevCloudGrips.setter
def RevCloudGrips(self, value: bool) -> None
Gets or sets AutoCAD's REVCLOUDGRIPS: whether a revision cloud shows the few grips of the shape it goes round, the default, or one at each of its vertices as any polyline does (see CadGrips.Shown). A cloud round the rectangle (0, 0) to (60, 40) with arcs 10 long has 8 grips at true, its 20 vertices and the middle of each arc at false. AutoCAD keeps it in the registry; here it lasts as long as the document is open.
SaveVersion
@property
def SaveVersion(self) -> str | None
Gets the version the drawing was last saved as by CadDocument.SaveAs and is saved as again: AC1032 for AutoCAD 2018, and so on; null where it was not saved so, its own version then, which a DWG is written as AutoCAD 2018 whatever it holds. For a DWG it is the version the DWG writer wrote: AC1027 for AutoCAD 2013.
Selection
@property
def Selection(self) -> CadSelection
Gets the selection.
SelectionCycling
@property
def SelectionCycling(self) -> int
@SelectionCycling.setter
def SelectionCycling(self, value: int) -> None
Gets or sets SELECTIONCYCLING, as AutoCAD's: 2 (the default) for the list of the objects under a pick where more than one lies there, 1 for cycling through them with Shift+Space only, 0 off; the window shows the list and cycles. Kept by the presenter, not in the drawing. Ctrl+W switches it between 0 and 2, as AutoCAD's does; the command SELECTIONCYCLING sets it.
Spaces
@property
def Spaces(self) -> System.Collections.Generic.IReadOnlyList[CadSpace]
Gets the spaces in the order of their tabs: model space first, then the layouts.
SupportFolders
@property
def SupportFolders(self) -> System.Collections.Generic.IReadOnlyList[str]
@SupportFolders.setter
def SupportFolders(self, value: System.Collections.Generic.IReadOnlyList[str]) -> None
Gets or sets the user's own folders the drawing's linetype files (.lin) and hatch pattern files (.pat) are looked for in, in order, before the Linetypes and Hatches folders beside the dll: none until set; the window sets Global settings' Support file search folders, empty by default. Blank entries are left out and a folder given twice is kept once.
TemplateDescription
@property
def TemplateDescription(self) -> str
Gets the description of the template the drawing was last saved as by CadDocument.SaveAsTemplate, written again when it is saved to a file ending in .dwt; empty where it was not.
TiledViewports
@property
def TiledViewports(self) -> CadTiledViewports
Gets the tiled viewports of model space, read from the drawing's VPORT table when first asked for, as CadTiledViewports says: one, the whole drawing area, until VPORTS splits it.
Title
@property
def Title(self) -> str
Gets the name of the file without its folder, or "Drawing" where it has none.
Ucs
@property
def Ucs(self) -> CadUcsManager
Gets the user coordinate systems of the drawing, read from it when first asked for, as CadUcsManager says: the current one of each space, the earlier ones and the named ones. A change to them is a step of undo, as in AutoCAD 2021, and is written into the drawing when it is saved.
WorkingSpace
@property
def WorkingSpace(self) -> CadSpace
Gets the space edits go into: model space while a viewport is worked through (CadDocument.ActiveViewport), else the space shown (CadDocument.CurrentSpace). A line drawn in a viewport of Layout1 goes into model space.
XFadeControl
@property
def XFadeControl(self) -> int
@XFadeControl.setter
def XFadeControl(self, value: int) -> None
Gets or sets XFADECTL, as AutoCAD's: how far the objects outside the working set are faded while a reference is edited in place, from 0 to 90 per cent, 70 as AutoCAD 2021 gives it. Kept by the presenter, not in the drawing, as AutoCAD keeps it in the registry.
Xrefs
@property
def Xrefs(self) -> CadXrefManager
Gets the external references and images of the drawing as the presenter shows them: the files found, the drawings read and what was unloaded (CadXrefManager). It outlives an undo, which reads the drawing anew, so a drawing referenced is read once.
Events
ActiveViewportChanged
@property
def ActiveViewportChanged(self) -> System.EventHandler[System.EventArgs]
@ActiveViewportChanged.setter
def ActiveViewportChanged(self, value: System.EventHandler[System.EventArgs]) -> None
Raised when model space is entered through a viewport, another viewport is made the one worked through, or the paper is worked on again.
BlockEditorChanged
@property
def BlockEditorChanged(self) -> System.EventHandler[System.EventArgs]
@BlockEditorChanged.setter
def BlockEditorChanged(self, value: System.EventHandler[System.EventArgs]) -> None
Raised when the Block Editor opens, closes, or turns to another block (Save Block As).
Changed
@property
def Changed(self) -> System.EventHandler[CadDocumentChangedEventArgs]
@Changed.setter
def Changed(self, value: System.EventHandler[CadDocumentChangedEventArgs]) -> None
Raised after the drawing changed: an edit applied, a step undone or redone, a regen, a save.
FontMissing
@property
def FontMissing(self) -> System.EventHandler[CadFontMissingEventArgs]
@FontMissing.setter
def FontMissing(self, value: System.EventHandler[CadFontMissingEventArgs]) -> None
Raised the first time a font a text style names is not found and is replaced, as the spaces are drawn. The first time for the fonts set, it says in one line every SHX font and big font the drawing's text styles name that is not found, and what each is drawn in, as AutoCAD lists its missing SHX files on opening a drawing (CadDocument.FindMissingFonts); a font not in that line is said once on its own when it is met.
LayerFilterChanged
@property
def LayerFilterChanged(self) -> System.EventHandler[System.EventArgs]
@LayerFilterChanged.setter
def LayerFilterChanged(self, value: System.EventHandler[System.EventArgs]) -> None
Raised when the chosen layer filter, its inversion or the use of it for the layer box changes.
RefEditChanged
@property
def RefEditChanged(self) -> System.EventHandler[System.EventArgs]
@RefEditChanged.setter
def RefEditChanged(self, value: System.EventHandler[System.EventArgs]) -> None
Raised when an in-place edit opens or closes.
Methods
AddToRefEdit
def AddToRefEdit(self, handles: System.Collections.Generic.IReadOnlyList[str]) -> CadEditResult
Adds objects of the drawing to the working set, as REFSET Add: they are written into the block when the edit is saved, and the objects of the block that were taken out of the set (CadDocument.RemoveFromRefEdit) go back into it. Objects that are in the set already, are not in the space the reference stands in, are the reference itself, or are references of the block being edited or of a block that places it (they would make it place itself) are left out. One undo step.
ApplyEdit
def ApplyEdit(
self,
name: str,
planned: System.Collections.Generic.IReadOnlyList[CadEditRecord],
apply: System.Action[CadEditScope],
) -> CadEditResult
Applies one edit: the one way the presenter changes the drawing. The gate (CadDocument.EditGate) is asked about every planned change of an existing entity first, and one refusal refuses the whole edit with nothing written. Then apply writes the change; if it throws, the drawing is read back as it stood before and the edit fails with the exception's message. A made edit is one undo step, or part of the open group's (CadDocument.BeginGroup); the display lists and pick indexes of the spaces it touched are dropped, and CadDocument.Changed is raised.
ApplySetting
def ApplySetting(
self,
name: str,
property: str,
read: System.Func[str],
change: System.Action[()],
replay: System.Action[CadDocument, bool],
joinsPrevious: bool,
) -> CadEditResult
Changes a setting kept in the drawing, one undo step, as AutoCAD 2021 records GRID, SNAP, SETVAR and a snap or grid variable typed alone: the step puts the setting back by what replay writes, keeps no copy of the drawing, and undoing or redoing it reads the drawing again no more than a zoom does. Inside a command's group (CadDocument.BeginGroup) the change joins the command's step instead. A change that leaves read giving the text it gave before makes no step.
BeginGroup
def BeginGroup(self, name: str) -> None
Opens a group of edits that becomes one undo step when it is closed, as a command that draws line after line is one step. Groups nest; the outermost names the step. An edit of the group that fails takes the whole group back.
BeginLayerSet
def BeginLayerSet(self) -> None
Opens a set of layer changes that LAYERP takes back together, as the Layer manager does for the length of its dialog: the changes made until CadDocument.EndLayerSet are one set, each still its own undo step. Sets nest; the outermost counts.
CancelGroup
def CancelGroup(self) -> None
Closes every open group and takes its edits back, the drawing read back as it stood before the group began, as a command that fails part way changes nothing.
CloseBlockEditor
def CloseBlockEditor(self, save: bool) -> CadEditResult
Closes the Block Editor, as BCLOSE: the block saved first (CadDocument.SaveBlock) where asked, else read back as it was opened or last saved (a new block never saved not made at all); the space shown before BEDIT shown again.
CloseRefEdit
def CloseRefEdit(self, save: bool) -> CadEditResult
Closes the in-place edit, as REFCLOSE: saved, each object of the working set written into the block as a new object put through the reference's transformation the other way and the object it came from erased (an object erased in the drawing leaves the block, one taken out of the set leaves it too), every reference of the block drawn anew; or discarded, the copies erased and the block as it was. The objects drawn in the drawing that were never added stay in it. The session's steps become one, "REFEDIT", which one undo takes back.
EndGroup
def EndGroup(self) -> None
Closes the group CadDocument.BeginGroup opened; the outermost makes its edits one undo step, if it made any.
EndLayerSet
def EndLayerSet(self) -> None
Closes the set CadDocument.BeginLayerSet opened; the outermost keeps what it changed, if it changed any layer's settings.
EnterViewport
def EnterViewport(self, handle: str) -> bool
Works in model space through a viewport of the layout shown, as a double click inside it does in AutoCAD: the selection is let go, and CadDocument.ActiveViewportChanged raised where it was not already the one.
FindEntity
def FindEntity(self, handle: str) -> DxfEntity
Gets the entity with a handle, or null.
FindMissingFonts
def FindMissingFonts(self) -> System.Collections.Generic.IReadOnlyList[CadMissingFont]
Gets the SHX fonts and big fonts the drawing's text styles name that CadDocument.Fonts does not find, each with what it is drawn in, in the order of their names: the list AutoCAD shows as Missing SHX files. A style of a TrueType font is left out, as AutoCAD leaves it out. Each can be given a font of its own by CadFonts.WithSubstitution, or left to the replacement font.
FindMissingTrueTypeFonts
def FindMissingTrueTypeFonts(self) -> System.Collections.Generic.IReadOnlyList[str]
Gets the TrueType families and files the drawing names that CadDocument.Fonts does not find: those of its text styles and those its MTEXTs switch to with a font code (\fGulim|b0|i0|c129|p50;), which CadDocument.FindMissingFonts leaves out. Each is drawn in the canvas's drawing font, the letters it lacks in another font the machine has. A name is listed once whatever its case, and the list is in the order of the names.
FindRefEditLevels
def FindRefEditLevels(
self,
handle: str,
at: GeoPoint2 | None,
aperture: float,
) -> System.Collections.Generic.IReadOnlyList[CadRefEditLevel]
The references a point on a reference of the drawing can mean, the outermost first: the reference itself, then each reference nested in its block whose objects reach the point, and each nested in those, as the Reference Edit dialog lists them. A reference with nothing nested at the point gives its own level alone.
FindRefEditObject
def FindRefEditObject(
self,
chain: System.Collections.Generic.IReadOnlyList[str],
at: GeoPoint2,
aperture: float,
) -> str
The object of the block a reference chain edits that a point reaches, as REFEDIT's "Prompt to select nested objects" takes one, the block's objects not being picked in the drawing: the one whose own line lies nearest the point, where it is within the aperture of it (a line, arc, circle, polyline or spline, put where the reference draws it, by its distance to the point, so that a point in the middle of a circle or in the box of a slanting line reaches neither); an object of no line of its own (a text, a hatch, a reference) by its box, put where the reference draws it, as near as the point is to the box. A tie goes to the object whose box is the smaller, and then to the first of the block; null for none.
FindRefEditObjects
def FindRefEditObjects(
self,
chain: System.Collections.Generic.IReadOnlyList[str],
first: GeoPoint2,
opposite: GeoPoint2,
) -> System.Collections.Generic.IReadOnlyList[str]
The objects of the block a reference chain edits that a window or a crossing takes, as REFEDIT's "Prompt to select nested objects" takes them when the point picked reaches no object and a second corner is given: the corners drawn from left to right make a window, taking the objects whose box, put where the reference draws it, lies wholly inside; from right to left a crossing, taking those whose box meets it.
FindSpace
def FindSpace(self, handle: str) -> CadSpace
Gets the space an entity of a handle is in, or null where no space holds it.
From
@staticmethod
def From(database: DxfDatabase, name: str | None = ...) -> CadDocument
Shows a database already in memory. One that writes no handles, as a drawing of R12 written by hand, is shown as a copy read anew with a handle for each entity, as AutoCAD gives them on opening it; CadDocument.Database is then that copy.
GetDisplay
def GetDisplay(self, space: CadSpace) -> DisplayList2
Gets the display list of a space, made on the first call and kept. After an edit, an undo or a redo the list is made again from the one before: the entities the edit's records name, and those that read a layer it switched or recoloured, are drawn anew and every other entity keeps its items, so that moving one line of a drawing of a million entities draws one line, not a million. The list is the one a REGEN would make, item for item; an edit of a table, a block or a setting that redraws everything (LTSCALE, PDMODE) still draws every entity of the spaces it touched.
GetPickIndex
def GetPickIndex(self, space: CadSpace) -> PickIndex
Gets the index that picks in a space, made on the first call and kept. Its picks put the entity drawn on top first among those at about the same distance while the drawing's SORTENTS holds its bit 1, read at each call (PickIndex.Pick).
GripDrag
def GripDrag(self, handle: str, gripIndex: int, newPoint: GeoPoint2) -> CadEditResult
Drags a grip of an entity to a point, one undo step, as CadGrips.Drag says.
KeepLayerFilter
def KeepLayerFilter(self) -> CadEditResult
Writes the filter the Layer manager has chosen into the drawing as the current one (group 290), one undo step, unless the drawing marks it already. A filter AutoCAD makes is not written: All marks none.
LeaveViewport
def LeaveViewport(self) -> None
Works on the paper of the layout shown again, as PSPACE: the selection let go; nothing where no viewport is worked through.
NextViewport
def NextViewport(self) -> bool
Works through the next viewport of the layout shown, in the order of CadDocument.EnterableViewports, the first after the last, as Ctrl+R does in AutoCAD.
Open
@staticmethod
def Open(path: str) -> CadDocument
Opens a DWG or DXF file: a DWG of AutoCAD 2000 to 2018 read by DwgReader, as CadDrawingFile.Open reads it, so that CadDocument.Save writes it back as a DWG of AutoCAD 2018. A DXF whose header leaves out MEASUREMENT, the dimension variables, DIMSTYLE or CELTYPE reads them as AutoCAD does (MEASUREMENT 0, the dimension style Standard with DIMASZ 0.18, CELTYPE Continuous), and writes them into its header; a drawing made by CadDocument.From keeps the library's own.
@staticmethod
def Open(stream: System.IO.Stream, name: str | None = ...) -> CadDocument
Opens a DXF from a stream, reading the header values it leaves out as CadDocument.Open does.
@staticmethod
def Open(path: str, progress: System.IProgress[float]) -> CadDocument
Opens a DWG or DXF file as CadDocument.Open does, telling how far the reading has got as CadDrawingFile.Open tells it: a share from 0 to 1, never going back, 1 once read. A CadProgressMeter is such a progress.
@staticmethod
def Open(
path: str,
progress: System.IProgress[float],
cancellationToken: System.Threading.CancellationToken,
) -> CadDocument
Opens a DWG or DXF file as CadDocument.Open does, giving it up when a token says so: the window opens a drawing on a worker thread that Esc and Stop stop. A DXF is looked at every 4 096 records as its text is walked, its handles scanned and its entities of model space listed (the listing the first display would otherwise make, 0.3 s at 1 000 000 entities), so that a file of that size, 77 MB, is given up within a few milliseconds of the stop and not at the end of its reading, which took 0.5 s; a DWG is looked at before each page of it is unpacked, before each object is read and before each entity and object is written as DXF, and then every 4 096 records as that DXF is walked, so that one of 300 000 entities, whose reading takes 1.6 s, is given up within a few milliseconds as well.
OpenBlockEditor
def OpenBlockEditor(self, name: str) -> CadEditResult
Opens the Block Editor on a block, as BEDIT: the block shown alone in a space of its own, made the current space; a name the drawing has no block of makes a new, empty block, its origin at (0, 0); <Current Drawing> opens model space itself. The selection is let go. The editor works in the World UCS, as AutoCAD's does, and UCS refuses to change it; closing the editor, whichever way, puts the UCS of model space back (CadUcsManager).
OpenRefEdit
def OpenRefEdit(
self,
chain: System.Collections.Generic.IReadOnlyList[str],
objects: System.Collections.Generic.IReadOnlyList[str],
) -> CadEditResult
Opens the in-place edit of a reference, as REFEDIT: the objects of its block copied into the drawing where the reference draws them, the working set. One undo step while the session lasts. The objects the reference's placing cannot hold (a circle under a scale unlike along its axes) are left in the block.
PrepareDisplay
def PrepareDisplay(
self,
space: CadSpace,
progress: System.IProgress[float],
cancellationToken: System.Threading.CancellationToken,
) -> None
Makes the display list and the pick index of a space now, as the first CadDocument.GetDisplay and CadDocument.GetPickIndex make them, saying how far it has got and stopping when asked: the window does it on a worker thread for a drawing it opens, so that a drawing of 1 000 000 entities, 7 s to draw, does not hold the window. The list is the one CadDocument.GetDisplay makes, item for item. A document is not safe to use from two threads at once: nothing else may use it, nor another document's fonts be set, until this returns.
RecordSpaceView
def RecordSpaceView(
self,
space: CadSpace,
view: CadView,
before: DisplayBox,
name: str,
realTime: bool,
) -> CadEditResult
Records that the view of a space has been zoomed or panned: one undo step, which puts the view back as it was before (U) or as it is now (REDO) with the drawing left alone, and an entry of the space's ZOOM Previous list, 20 at most. The wheel and the middle button of the canvas call it once their gesture is done; ZOOM, PAN and PLAN call it too. A zoom or a pan of the wheel or the middle button made straight after another joins its step, as AutoCAD 2021 combines consecutive real-time zooms and pans; typed ones stay a step each. A step is named ZOOM or PAN.
Redo
def Redo(self) -> bool
Redoes the step undone last.
RefEditLockedHandles
def RefEditLockedHandles(self) -> System.Collections.Generic.IReadOnlyList[str]
The handles of the objects the canvas fades while an edit is open, in ordinal order: those the lock holds (the ones in the spaces that are not in the working set and were there before the session). Empty where no edit is open or the lock is off.
Regen
def Regen(self) -> None
Drops every display list and pick index, so that each space is drawn again from the drawing, as REGEN does.
ReleaseSnapshot
def ReleaseSnapshot(self, snapshot: CadSnapshot) -> None
Lets go of the drawing read ahead for the next reset to the snapshot, which a program that is done with the snapshot would otherwise leave held until the next reset to another. The snapshot itself stays valid, and is reset to as before, the first reset then slower.
RemoveFromRefEdit
def RemoveFromRefEdit(self, handles: System.Collections.Generic.IReadOnlyList[str]) -> CadEditResult
Takes objects out of the working set, as REFSET Remove: they stay in the drawing as its own objects, and the objects of the block they came from leave the block when the edit is saved, and come back to it if the edit is discarded; an object added to the set from the drawing is simply the drawing's again. Objects not in the set are left out. One undo step.
Reset
def Reset(self, snapshot: CadSnapshot) -> None
Puts the drawing back as it stood when the snapshot was taken: its entities, tables, layouts, handles and header variables (the current layer and styles, $HANDSEED), the view of each space and the settings the steps changed. The steps made since are forgotten, so the drawing can be reset again and again from one snapshot. Selected entities that are still in the drawing stay selected.
Save
def Save(self) -> None
Saves the drawing to the file it was opened from or last saved as.
SaveAs
def SaveAs(self, path: str) -> None
Saves the drawing to a file, which it is then known by: a DWG where its name ends in .dwg, of the version the drawing was last saved as (CadDocument.SaveVersion) where the DWG writer writes it, else of AutoCAD 2018, what the DWG writer does not write yet left out and said in CadDocument.LeftOutOfDwg; else a DXF, in the version the drawing was last saved as, its own where it was not. The file is written to a temporary file beside it and put in the place of the one there only when whole, so that a save that fails part way leaves the old file as it was. The old file is not kept as a .bak by this method; QSAVE, SAVEAS and SAVE keep it as plan.bak where ISAVEBAK is 1. The editing time and the user's timer are written into the file ($TDINDWG, $TDUSRTIMER, $USRTIMER).
def SaveAs(self, path: str, progress: System.IProgress[float]) -> None
Saves the drawing to a file as CadDocument.SaveAs does, telling how far the writing has got as a share from 0 to 1: in thousandths, never going back, 0 first and 1 at the end. A DWG tells it some 1 000 times; a DXF, written at once from its bytes, 0 and 1. A CadProgressMeter is such a progress.
def SaveAs(self, path: str, version: str, progress: System.IProgress[float]) -> None
Saves the drawing to a file in a version of AutoCAD, as AutoCAD 2021's Save Drawing As does with the type chosen: a DWG of R2000 (AC1015), R2004 (AC1018), R2007 (AC1021), R2010 (AC1024), R2013 (AC1027) or R2018 (AC1032) where the name ends in .dwg, as DwgWriter writes it; else a DXF of R12 (AC1009), R2000 (AC1015), R2004 (AC1018), R2007 (AC1021), R2010 (AC1024), R2013 (AC1027) or R2018 (AC1032), as DxfDatabase.Save writes it; the version is kept in CadDocument.SaveVersion, so that CadDocument.Save writes it again, as AutoCAD's QSAVE keeps the format of the last Save As. What a DXF of the version could not hold is said in CadDocument.LeftOutOfDxf, and what a DWG of it does not write yet in CadDocument.LeftOutOfDwg.
SaveAsTemplate
def SaveAsTemplate(self, path: str, description: str, metric: bool, progress: System.IProgress[float]) -> None
Saves the drawing as a drawing template, as AutoCAD 2021's Save Drawing As does with the type AutoCAD Drawing Template (*.dwt) and its Template Options: a DWG of AutoCAD 2018 with the extension .dwt (given where the name ends otherwise), the description kept in the file's template section and MEASUREMENT set as chosen. The drawing is then known by the template's file, as AutoCAD's is, and CadDocument.Save writes it again with the same description.
SaveBlock
def SaveBlock(self) -> CadEditResult
Saves the block open in the Block Editor, as BSAVE: its edits made final, every INSERT of it drawn anew (their attributes are not synchronised, as AutoCAD's ATTSYNC is not run), the anonymous *U blocks the INSERTs of a dynamic block place worked out anew from it at their values, as AutoCAD's UpdateAnonymousBlocks works them, and the steps of the session so far one undo step, "BEDIT". Undo inside the editor then stops here. For <Current Drawing> model space keeps its edits.
SaveBlockAs
def SaveBlockAs(self, name: str) -> CadEditResult
Saves the content of the Block Editor as a new block, as BSAVEAS: the block opened is read back as it was opened or last saved, the new one holds the content as it is now with the base point, unit, description and flags of the block opened, and the editor goes on with the new block. The session stays one undo step.
SaveCopy
def SaveCopy(self, path: str, version: str) -> System.Collections.Generic.IReadOnlyList[str]
Writes a copy of the drawing as a DXF of a version, as AutoCAD's DXFOUT does: the drawing keeps its file, its CadDocument.SaveVersion and whether it has changes not saved, and the copy is not the file it is known by. The objects ISOLATEOBJECTS and HIDEOBJECTS hid for the session are written shown, as a save writes them, and the file is written to a temporary file first and put in place when whole, with no .bak of the file it replaces.
SavingInGroup
def SavingInGroup(self, save: System.Action[()]) -> None
Runs a save from inside a group of edits, which CadDocument.Save and CadDocument.SaveAs refuse: the group is closed for the save, so that what it has made so far is a step the drawing is saved with, and opened again after it, under the same name and as deep. Its edits after the save are a step that joins the first, so that one undo takes back both, as it takes back a group nothing was saved in. A group left open with no edit made yet makes no step, and the edits after the save are the group's step alone. A group cancelled after the save takes back only what followed it: the file cannot be taken back, and the step it was saved with stays. With no group open the save is simply run.
SetBlockEditorVisibilityState
def SetBlockEditorVisibilityState(self, state: str) -> CadEditResult
Shows another visibility state of the block open in the Block Editor, as AutoCAD's Visibility State box: the entities the state hides are no longer drawn or picked, those it shows and those no state lists are. A view of the block, not an edit of it: nothing is written and no undo step made.
SetViewportView
def SetViewportView(self, handle: str, viewCenter: GeoPoint2, viewHeight: float, name: str) -> CadEditResult
Sets the view a viewport shows of model space, one undo step: the point at the middle of its frame and the height it shows, so its scale is its height over that one. A viewport 150 high given a view 3 000 high shows model space at 1:20. The view it showed goes on the viewport's ZOOM Previous list, 20 at most.
def SetViewportView(
self,
handle: str,
viewCenter: GeoPoint2,
viewHeight: float,
name: str,
realTime: bool,
) -> CadEditResult
Sets the view a viewport shows of model space, as CadDocument.SetViewportView; a real-time zoom or pan, the wheel's or the middle button's, made straight after another joins its undo step, as AutoCAD 2021 combines consecutive real-time zooms and pans where UNDO Control Combine is Yes (UNDOCTL has its 16; the machine measured has No, UNDOCTL 13, and the presenter starts as it does); with UNDO Control Combine No each is a step of its own. ZOOM and PAN typed stay a step each, as AutoCAD's console undoes ZOOM 2X, ZOOM 2X and -PAN one U each.
ShowSpace
def ShowSpace(self, space: CadSpace) -> CadEditResult
Shows a space, model space or a layout, as a click on its tab does: one undo step named LAYOUT, which U takes back to the space shown before and REDO forward, as AutoCAD 2021's console undoes LAYOUT Set (probed: after switching from Model to Layout1 and to Layout2, two U took it back to Layout1 and to Model, each layout keeping the view it had). The step keeps no copy of the drawing, so an undo of it reads nothing again. The selection, which belongs to a space, is cleared by the switch and by its undo. Inside a command's group the switch joins the command's step.
TakeSnapshot
def TakeSnapshot(self) -> CadSnapshot
Keeps the drawing as it stands, to be put back with CadDocument.Reset. The undo list is left as it is; the drawing is saved once if it has not been, and again (compressed) only where a setting changed since the list kept it is not in the kept drawing.
ToolbarLayers
def ToolbarLayers(self) -> System.Collections.Generic.IReadOnlyList[CadLayerInfo]
Gets the layers the layer box lists: all of them, or where CadDocument.ApplyLayerFilterToToolbar is on those the chosen filter lets through (the others where CadDocument.InvertLayerFilter is on) and the current layer; in no order.
Undo
def Undo(self) -> bool
Undoes the last step: the drawing is read back as it stood before it (see the remarks of the class).
WithGroups
def WithGroups(
self,
handles: System.Collections.Generic.IEnumerable[str],
) -> System.Collections.Generic.IReadOnlyList[str]
Gets the objects a pick takes with PICKSTYLE on: those given, then the other members of each selectable group any of them is in, in ordinal order of their handles. A line and a circle of the group G1 and a text of none: picking the line gives the line and the circle. With PICKSTYLE off, those given. Either way a viewport clipped by an entity is taken with it, and the entity with its viewport (CadViewportClips.WithPartners).