Table of Contents

Class CadCommandContext

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

What a command's body works with while it runs: the document, the answer to its last prompt, the objects selected, and the way to make its edit. One context lives for one run of a command.

public sealed class CadCommandContext
Inheritance
CadCommandContext
Inherited Members

Properties

ClearsSelection

Gets or sets whether the document's selection is cleared when the command ends, as AutoCAD clears it after MOVE.

Command

Gets the command.

Database

Gets the drawing as it stands now; a new object after an undo, so it is read again each time rather than kept.

Document

Gets the document.

Documents

Gets the drawings open in the app: the list, the one shown, and the calls that open, make, show or close one. A command may read the list and close another drawing; opening, making and showing a drawing end the command running, so they are refused here (see CadDocuments).

Editor

Gets the editor of the session: the view, the selection by area, the system variables and the named views. A view call made while the command runs is part of the command's undo step.

Input

Gets the answer to the last prompt.

Progress

Gets the progress meter of the status bar, for long work: using (var meter = c.Progress.Start("Checking")), then SetLimit(int) and MeterProgress().

Selected

Gets the objects SelectObjects() gave, in ordinal order, those on locked layers left out.

Session

Gets the session the command runs in.

Space

Gets the space the command works in: the document's working space, model space while a viewport of the layout shown is worked through.

Methods

Apply(IReadOnlyList<CadEditRecord>, Action<CadEditScope>)

Makes an edit of the command through ApplyEdit(string, IReadOnlyList<CadEditRecord>, Action<CadEditScope>); all the edits of one run are one undo step. A refusal or failure is written into the history.

CloseUndoStep()

Closes the command's undo step opened so far, so that its edits up to now are one step and those it makes next another, as TEXTEDIT makes one step of each text it edits.

Length(double)

Writes a length as the command line writes one: to 4 places.

OpenUndoStep()

Opens the command's undo step now, so that edits made through the document's own methods (CadLayerEditor, CadGrips, CadPropertyEditor) join it rather than being steps of their own.

Remember(string, double)

Keeps a number for the next run of a command.

Remembered(string, double)

Gets a number kept from a run of a command before, as the radius CIRCLE offers next.

SelectObjects()

Asks "Select objects:" until Enter, unless objects were selected before the command started, which are taken instead; the result is Selected, those on a locked layer left out with "1 was on a locked layer." The body yields what this yields: foreach (CadPrompt p in c.SelectObjects()) yield return p;.

Write(string)

Writes a line into the history of the command line.