Class CadDocument
- Namespace
- OpenCAD2D
- Assembly
- OpenCAD2D.Core.dll
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.
public sealed class CadDocument
- Inheritance
-
CadDocument
- Inherited Members
Remarks
The edits are written into the block at once and each is a step of undo, as in AutoCAD; undo stops at the state the block was opened or last saved in. Save Block (BSAVE) makes them final: the steps of the session so far become one, "BEDIT", and every INSERT of the block is drawn anew; closing without saving reads the drawing back as it stood when the block was opened or last saved. After the editor closes, one undo takes back the whole session. A door of 4 objects opened, given a fifth line and saved, is one step "BEDIT" that every INSERT of the door shows with its five; a dynamic panel given a circle and saved has each INSERT of Width 150 or 200 placing a new *U block, stretched to its width, with the circle.
Properties
- ActiveViewport
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
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
Gets or sets whether the layer box lists only the layers the filter lets through, the current layer always among them.
- BlockEditor
Gets the Block Editor open on this drawing; null where none is.
- CanRedo
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
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
Gets the constraint bars of the document: which are shown, and the icons of each.
- CurrentSpace
Gets or sets the space the canvas shows; see WorkingSpace for the one edits go into.
- Database
Gets the drawing.
- DefaultLineWeight
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 Regen().
- EditGate
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 Owners (CadOwnerEditGate) until another is given, and again when set to null. With no owner registered it lets every edit through.
- EnterableViewports
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
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
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
Gets the full path of the file it was opened from, or the name it was given; null for neither.
- Fonts
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
Gets whether the drawing has a file of its own to Save() to: it was opened from one or saved as one.
- HatchBeingEdited
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
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
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
Gets whether a group of edits is open, as while a command runs.
- IsModified
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
Gets whether a viewport of the layout shown is maximized (MaximizedViewportHandle).
- LayerFilterPath
Gets or sets the names, from the top, of the filter the Layer manager lists the layers of:
Steel,Beamsfor 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
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
Gets the layers of the drawing.
- LeftOutOfDwg
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
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 Save(string, string) says them. Empty where nothing was, or the drawing was last saved as a DWG or in its own version.
- MaximizedViewportHandle
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
Gets model space.
- OleFrame
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 Regen().
- OleHide
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 Regen().
- OleQuality
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
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
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 Regen().
- PdfOsnap
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
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
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
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
Gets or sets the folder the plot style tables a plot names (StyleSheet) are read from, as CadPlotStyleFolder lists them: empty, the default, for no folder, when the tables the presenter makes (BuiltIn(string)) stand in and nothing is read from disk. The window sets Global settings' plot style folder, DefaultPath where that is empty.
- PointViewHeight
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 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
Gets the in-place edit open on this drawing (REFEDIT); null where none is.
- RefEditAttributeDefinitions
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
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
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$WALLin 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
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 Shown(CadDocument, DxfEntity)). 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
Gets the version the drawing was last saved as by SaveAs(string, string, IProgress<double>) 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
Gets the selection.
- SelectionCycling
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
Gets the spaces in the order of their tabs: model space first, then the layouts.
- SupportFolders
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
Gets the description of the template the drawing was last saved as by SaveAsTemplate(string, string, bool, IProgress<double>), written again when it is saved to a file ending in .dwt; empty where it was not.
- TiledViewports
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
Gets the name of the file without its folder, or "Drawing" where it has none.
- Ucs
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
Gets the space edits go into: model space while a viewport is worked through (ActiveViewport), else the space shown (CurrentSpace). A line drawn in a viewport of Layout1 goes into model space.
- XFadeControl
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
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.
Methods
- AddToRefEdit(IReadOnlyList<string>)
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 (RemoveFromRefEdit(IReadOnlyList<string>)) 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(string, IReadOnlyList<CadEditRecord>, Action<CadEditScope>)
Applies one edit: the one way the presenter changes the drawing. The gate (EditGate) is asked about every planned change of an existing entity first, and one refusal refuses the whole edit with nothing written. Then
applywrites 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 (BeginGroup(string)); the display lists and pick indexes of the spaces it touched are dropped, and Changed is raised.
- ApplySetting(string, string, Func<string>, Action, Action<CadDocument, bool>, bool)
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
replaywrites, 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 (BeginGroup(string)) the change joins the command's step instead. A change that leavesreadgiving the text it gave before makes no step.
- BeginGroup(string)
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()
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 EndLayerSet() are one set, each still its own undo step. Sets nest; the outermost counts.
- CancelGroup()
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(bool)
Closes the Block Editor, as BCLOSE: the block saved first (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(bool)
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()
Closes the group BeginGroup(string) opened; the outermost makes its edits one undo step, if it made any.
- EndLayerSet()
Closes the set BeginLayerSet() opened; the outermost keeps what it changed, if it changed any layer's settings.
- EnterViewport(string)
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 ActiveViewportChanged raised where it was not already the one.
- FindEntity(string)
Gets the entity with a handle, or null.
- FindMissingFonts()
Gets the SHX fonts and big fonts the drawing's text styles name that 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 WithSubstitution(string, string), or left to the replacement font.
- FindMissingTrueTypeFonts()
Gets the TrueType families and files the drawing names that 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 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(string, GeoPoint2?, double)
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(IReadOnlyList<string>, GeoPoint2, double)
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(IReadOnlyList<string>, GeoPoint2, GeoPoint2)
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(string)
Gets the space an entity of a handle is in, or null where no space holds it.
- From(DxfDatabase, string)
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; Database is then that copy.
- GetDisplay(CadSpace)
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(CadSpace)
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 (Pick(double, double, double)).
- GripDrag(string, int, GeoPoint2)
Drags a grip of an entity to a point, one undo step, as Drag(CadDocument, string, int, GeoPoint2) says.
- KeepLayerFilter()
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()
Works on the paper of the layout shown again, as PSPACE: the selection let go; nothing where no viewport is worked through.
- NextViewport()
Works through the next viewport of the layout shown, in the order of EnterableViewports, the first after the last, as Ctrl+R does in AutoCAD.
- Open(Stream, string)
Opens a DXF from a stream, reading the header values it leaves out as Open(string) does.
- Open(string)
Opens a DWG or DXF file: a DWG of AutoCAD 2000 to 2018 read by DwgReader, as Open(string) reads it, so that 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 From(DxfDatabase, string) keeps the library's own.
- Open(string, IProgress<double>)
Opens a DWG or DXF file as Open(string) does, telling how far the reading has got as Open(string, IProgress<double>) tells it: a share from 0 to 1, never going back, 1 once read. A CadProgressMeter is such a progress.
- Open(string, IProgress<double>, CancellationToken)
Opens a DWG or DXF file as Open(string, IProgress<double>) 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(string)
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(IReadOnlyList<string>, IReadOnlyList<string>)
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(CadSpace, IProgress<double>, CancellationToken)
Makes the display list and the pick index of a space now, as the first GetDisplay(CadSpace) and GetPickIndex(CadSpace) 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 GetDisplay(CadSpace) 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(CadSpace, CadView, DisplayBox, string, bool)
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()
Redoes the step undone last.
- RefEditLockedHandles()
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()
Drops every display list and pick index, so that each space is drawn again from the drawing, as REGEN does.
- ReleaseSnapshot(CadSnapshot)
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(IReadOnlyList<string>)
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(CadSnapshot)
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()
Saves the drawing to the file it was opened from or last saved as.
- SaveAs(string)
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 (SaveVersion) where the DWG writer writes it, else of AutoCAD 2018, what the DWG writer does not write yet left out and said in 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.bakwhere ISAVEBAK is 1. The editing time and the user's timer are written into the file ($TDINDWG,$TDUSRTIMER,$USRTIMER).
- SaveAs(string, IProgress<double>)
Saves the drawing to a file as SaveAs(string) 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.
- SaveAs(string, string, IProgress<double>)
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 Save(string, string) writes it; the version is kept in SaveVersion, so that 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 LeftOutOfDxf, and what a DWG of it does not write yet in LeftOutOfDwg.
- SaveAsTemplate(string, string, bool, IProgress<double>)
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 Save() writes it again with the same description.
- SaveBlock()
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
UpdateAnonymousBlocksworks 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(string)
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(string, string)
Writes a copy of the drawing as a DXF of a version, as AutoCAD's
DXFOUTdoes: the drawing keeps its file, its 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(Action)
Runs a save from inside a group of edits, which Save() and SaveAs(string) 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(string)
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(string, GeoPoint2, double, string)
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.
- SetViewportView(string, GeoPoint2, double, string, bool)
Sets the view a viewport shows of model space, as SetViewportView(string, GeoPoint2, double, string); 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(CadSpace)
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()
Keeps the drawing as it stands, to be put back with Reset(CadSnapshot). 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()
Gets the layers the layer box lists: all of them, or where ApplyLayerFilterToToolbar is on those the chosen filter lets through (the others where InvertLayerFilter is on) and the current layer; in no order.
- Undo()
Undoes the last step: the drawing is read back as it stood before it (see the remarks of the class).
- WithGroups(IEnumerable<string>)
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 (WithPartners(CadDocument, IEnumerable<string>)).
Events
- ActiveViewportChanged
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
Raised when the Block Editor opens, closes, or turns to another block (Save Block As).
- Changed
Raised after the drawing changed: an edit applied, a step undone or redone, a regen, a save.
- FontMissing
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 (FindMissingFonts()); a font not in that line is said once on its own when it is met.
- LayerFilterChanged
Raised when the chosen layer filter, its inversion or the use of it for the layer box changes.
- RefEditChanged
Raised when an in-place edit opens or closes.