Table of Contents

Class CadEditor

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

What a plugin, a program driving the app through Remote and a Python script do to a drawing's session with a call instead of a typed command, as AutoCAD's Editor does: move the view (zoom, pan, regenerate), keep named views, select by an area, and read and set system variables. Every call does what the command of its name does, through the code the command runs: ZoomWindow(GeoPoint2, GeoPoint2) fits the window as ZOOM Window does and is the same step of undo, so that U after it puts the view back, and a drawing's view moved by a call is the view a typed ZOOM moves.

public sealed class CadEditor
Inheritance
CadEditor
Inherited Members

Remarks

Units are those of the drawing, in millimetres where the drawing is. Points are of the world, not of the UCS, as AutoCAD's .NET API takes them. A session with no window (a test, a plugin's own test, the Remote test server) has a view of its own, 942 by 534 pixels showing 10 units of height about the origin as AutoCAD 2021's console starts a drawing, which the view calls work on; HasWindow says false there.

A call made while a command runs in the session (a plugin's command, the run of a Python tool) joins the command's undo step; one made at rest is a step of its own, named as the command is: ZOOM, PAN, VIEW or SETVAR.

Through a viewport (MSPACE on a layout) zoom Extents, Window, Scaled and Previous and Pan change the viewport's view, as ZOOM and -PAN do there; zoom Center and Objects are refused, as ZOOM does not offer them there. Where the viewport is locked the paper is zoomed and panned.

Properties

Document

Gets the drawing the editor works on.

HasWindow

Gets whether the session has a window's view (View): false in a test and in the Remote test server, where the view calls work on the view the session keeps of its own.

NamedViews

Gets the names of the named views of the drawing, as -VIEW ? lists them: the views of model space and of the layouts together, in ordinal order, letters of either case alike.

Methods

Check(Action<CadEditor>)

Checks an edit without making it: runs the call the delegate makes, with every check the call makes (its arguments, its objects, the plan of the edit and the owner's gate) and none of its writing, and says what refused it. A Move of a line on the locked layer Steel checks to The object 2F is on the locked layer Steel.; an Offset of a circle of radius 10 inward by 15 to Cannot offset that object.; a Copy of a line to null, and no copy is made.

Copy<T>(IEnumerable<T>, GeoVector2)

Copies objects by a displacement, as COPY does with a displacement typed: two lines copied by (0, 50) leave the lines and add two lines 50 above them, on the layers of the lines they copy. A dimension copied with the line it is tied to is tied to the copy of the line. One undo step named COPY.

DeleteView(string)

Erases a named view with its layer snapshot, as -VIEW Delete does. One undo step named VIEW.

Erase(IEnumerable<DxfEntity>)

Erases objects, as ERASE does: the drawing then has none of them, and an undo brings them back. One undo step named ERASE.

GetCurrentView()

Gets the part of the space shown that the canvas shows: the whole canvas, so wider or taller than a box set where the shape differs.

GetVariable(string)

Gets the value of a system variable as AutoLISP's getvar gives it: an int for a whole number or a switch, a double for a real (an angle in radians), a string for a text, and a double[] of three coordinates for a point, of two for a variable AutoCAD keeps as a 2D point (SNAPBASE). A variable is the drawing's own: another drawing has its own value.

Mirror<T>(IEnumerable<T>, GeoPoint2, GeoPoint2, bool)

Mirrors objects across the line through two points, as MIRROR does: a TEXT stays readable under MIRRTEXT 0 and is written backwards under 1, a hatch's pattern is kept under MIRRHATCH 0, a dimension stays readable. A line from (0, 0) to (0, 50) mirrored across the line (0, 0) to (10, 0) gives a line from (0, 0) to (0, -50). One undo step named MIRROR.

Move<T>(IEnumerable<T>, GeoVector2)

Moves objects by a displacement, as MOVE does: a line from (0, 0) to (100, 0) moved by (10, 5) runs from (10, 5) to (110, 5). One undo step named MOVE.

Offset(DxfCurve, double, GeoPoint2)

Offsets a curve to the side of a point, as one pick of OFFSET with a distance typed: a line from (0, 0) to (100, 0) offset by 5 toward (50, 10) gives a line from (0, 5) to (100, 5). The copies go on the layer of the curve, which is kept (OFFSET's defaults; its Erase, Layer and Through options are not taken). A line goes to the side of the point across it, an arc or a circle outward where the point is outside it, a polyline to the side of the point with its corners run on until they meet. One undo step named OFFSET.

Pan(GeoVector2)

Pans the view so that the drawing moves by the displacement, as -PAN does: (10, 0) moves what is drawn 10 to the right, so that the view shows 10 less at the left. One undo step named PAN.

Regen()

Regenerates the drawing, as REGEN does without writing its line: the fields of a regeneration are evaluated again, the temporary graphics cleared, the display lists made again, and the size of a point of relative size taken from the view. It is no step of undo.

RestoreView(string)

Shows a named view, as -VIEW Restore does: the space it was saved in made the one shown where another is, the canvas zoomed to it, and its layer snapshot restored where it has one. Restoring on screen is no step of undo of its own.

Rotate<T>(IEnumerable<T>, GeoPoint2, double)

Turns objects about a base point, as ROTATE does: counter-clockwise, the angle taken from nought up to a whole turn first as ROTATE takes it (a turn of 2 pi is none, -pi / 2 is three quarters, which a hatch's pattern lines show). A line from (0, 0) to (100, 0) turned about (0, 0) by pi / 2 runs from (0, 0) to (0, 100). One undo step named ROTATE.

SaveView(string)

Saves the view on screen under a name, as -VIEW Save does, with no layer snapshot; a name that is a view's already redefines it. The view is saved in the space shown, a layout's with the layout. One undo step named VIEW.

Scale<T>(IEnumerable<T>, GeoPoint2, double)

Scales objects about a base point, as SCALE does: a circle of radius 10 about (200, 0) scaled about (0, 0) by 2 is one of radius 20 about (400, 0), and a text 5 high is 10 high. One undo step named SCALE.

SelectAll(Func<DxfEntity, bool>)

Gives the objects of the working space (model space while a viewport is worked through, else the space shown), as the All option of "Select objects:" takes them: the first viewport of a layout left out, objects on locked layers in. The pickfirst selection of the drawing is not changed: set it with Selection.

SelectCrossingWindow(GeoPoint2, GeoPoint2)

Gives the objects a window lies across or contains, as the Crossing option of "Select objects:" takes them, held to the view as SelectWindow(GeoPoint2, GeoPoint2) is. The pickfirst selection is not changed.

SelectWindow(GeoPoint2, GeoPoint2)

Gives the objects that lie wholly inside a window, as the Window option of "Select objects:" takes them. Where the session has a window, only objects the view shows are taken, as AutoCAD's does; with none, every object. Objects on locked layers are in. The pickfirst selection is not changed.

SetCurrentView(DisplayBox)

Sets the view to show a box, fitted with no margin as ZOOM Window fits one: the canvas shows the whole box and, along one axis, more. One undo step named ZOOM.

SetVariable(string, object)

Sets a system variable as AutoLISP's setvar does, through the variable's own rules: a whole number may be given as a real that is whole, a real as a whole number, an angle in radians. A variable the drawing keeps is one undo step named SETVAR (none where the value is the one it has); one the app keeps is set at once.

ZoomCenter(GeoPoint2, double)

Zooms to a height about a centre, as ZOOM Center: the view shows the height given and as much width as the canvas has. In the reference view the centre (50, 50) and the height 20 show (32.360, 40) to (67.640, 60). One undo step named ZOOM.

ZoomExtents()

Zooms to the extents, as ZOOM Extents: what the space shown draws and, on a layout, its sheet, fitted with a margin of 5 %. The reference drawing of a line from (0, 0) to (100, 0) and a circle about (50, 50) of radius 25, in a view 942 by 534 pixels, shows (-23.502, -4.167) to (123.502, 79.167). One undo step named ZOOM.

ZoomObjects(IEnumerable<string>)

Zooms to objects, as ZOOM Object: the box of the objects as the space shown draws them, fitted with a margin of 5 %. Objects that are not drawn in the space shown (of another layout, erased, not in the drawing) leave the view as it was, and so does a list with none. This is not the Find dialog's zoom, which switches space. One undo step named ZOOM, none where the view stays.

ZoomPrevious()

Goes back to the view before the last zoom or pan of the space shown (of the viewport worked through), as ZOOM Previous; 20 are kept. One undo step named ZOOM.

ZoomScaled(double)

Scales the view as it is about its centre, as ZOOM nX: 2 shows half the width and half the height, 0.5 twice as much. One undo step named ZOOM.

ZoomWindow(GeoPoint2, GeoPoint2)

Zooms to a window, as ZOOM Window: the window fitted with no margin, the view as wide or as high as the canvas shape makes it. In the reference view the window (0, 0) to (10, 10) shows (-3.820, 0) to (13.820, 10). Through a locked viewport the corners are points of model space, shown on the paper where it zooms. One undo step named ZOOM.