Table of Contents

CadPluginContext

from OpenCAD2D.Plugins import CadPluginContext

class CadPluginContext(System.Object) ยท CadPluginContext in the .NET reference

What a callback of a plugin is given when the window runs it: a ribbon button's, a DRAWINGS button's, a menu item's, a button's CanRun or a contextual tab's ShowWhen. A callback edits the drawing through CadDocument.ApplyEdit (one undo step each), or the editors commands use, as a command does.

Properties and fields

Document

.NET

@property
def Document(self) -> CadDocument | None

Gets the drawing the window shows; null where none is open.

Documents

.NET

@property
def Documents(self) -> CadDocuments

Gets the drawings open in the app, as AutoCAD's DocumentManager holds them: the list, the active one, and the calls that open a file, add a new drawing, show one and close one. A callback of a button, a menu item or a DRAWINGS row, where no command runs, may call them all. A plugin that uses it states [assembly: CadPluginApi("1.4")].

Editor

.NET

@property
def Editor(self) -> CadEditor | None

Gets the editor of the drawing the window shows (CadCommandSession.Editor): its view, the selection by area, the system variables and the named views; null where no drawing is open. A plugin that uses it states [assembly: CadPluginApi("1.3")].

IsCommandRunning

.NET

@property
def IsCommandRunning(self) -> bool

Gets whether a command is running on the command line.

Selected

.NET

@property
def Selected(self) -> System.Collections.Generic.IReadOnlyList[str]

Gets the handles of the objects selected, in ordinal order; empty for none.

Methods

RunCommand

.NET

def RunCommand(self, command: str) -> None

Starts a command as the presenter's ribbon buttons do, a command running cancelled first, as AutoCAD's ^C^C is: "NUMCIRCLES", "_NUMCIRCLES" and ".NUMCIRCLES" start the same command.

Write

.NET

def Write(self, line: str) -> None

Writes a line on the command line, as a command's message is.