Table of Contents

CadPlugin

from OpenCAD2D.Plugins import CadPlugin

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

A command plugin made from its assemblies: the methods marked CadCommandAttribute as commands, the properties marked CadSettingAttribute as settings, found by reflection, and added to the command lines of the open drawings with CadPlugin.AddTo.

Properties and fields

ApiVersion

.NET

ApiVersion: ClassVar[System.Version]

Gets the version of the plugin API this build of the presenter has: 1.5. Version 1.1 added what ICadPluginApplication and CadPluginHost give the window; 1.2 added the slide-outs and dialog launchers of CadRibbonPanel and the macro buttons of CadRibbonButton; 1.3 added the CadEditor of CadCommandContext.Editor and CadPluginContext.Editor; 1.4 added the CadDocuments of CadCommandContext.Documents and CadPluginContext.Documents; 1.5 added CadEditor.Check. A plugin that uses the first states [assembly: CadPluginApi("1.1")], one that uses the second "1.2", one that uses the third "1.3", one that uses the fourth "1.4", one that uses the fifth "1.5".

Commands

.NET

@property
def Commands(self) -> System.Collections.Generic.IReadOnlyList[CadPluginCommand]

Gets the commands, in ordinal order of their names.

Host

.NET

@property
def Host(self) -> CadPluginHost

Gets what the plugin's application classes added to the window in ICadPluginApplication.Initialize; never null, and empty for a plugin that has none.

IsEnabled

.NET

@property
def IsEnabled(self) -> bool

Gets whether its commands still run; false once it is unloaded, after which a run of one that was going on fails.

Name

.NET

@property
def Name(self) -> str

Gets the plugin's name: the name of its manifest, or of its assembly.

Problems

.NET

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

Gets what was left out while the plugin was read, a line each: a method marked as a command that cannot be one, a name taken twice.

RequiredApiVersion

.NET

@property
def RequiredApiVersion(self) -> System.Version

Gets the least version of the plugin API its assemblies state they need; 1.0 where none states one.

Settings

.NET

@property
def Settings(self) -> System.Collections.Generic.IReadOnlyList[CadPluginSetting]

Gets the settings, by the full name of the class that declares each, then in the order the class declares them.

Version

.NET

@property
def Version(self) -> str

Gets the plugin's version: its manifest's, or its first assembly's informational or assembly version.

Methods

AddTo

.NET

def AddTo(self, registry: CadCommandRegistry) -> System.Collections.Generic.IReadOnlyList[str]

Adds the commands to a registry, and their aliases to its shortcuts. A command whose name is already a command or an alias of the registry is left out, and so is an alias already taken; each is said in the lines returned.

FromAssemblies

.NET

@staticmethod
def FromAssemblies(
    name: str,
    assemblies: System.Collections.Generic.IEnumerable[System.Reflection.Assembly],
    version: str | None = ...,
) -> CadPlugin

Makes a plugin from its assemblies, already loaded. A plugin that states a newer version of the plugin API than CadPlugin.ApiVersion, or that has neither a command nor a class that implements ICadPluginApplication, is refused; a method marked as a command that cannot be one is left out and said in CadPlugin.Problems. Each application class is made and initialised, in ordinal order of its full name; CadPluginHost.Folder is the folder of the first assembly.

RemoveFrom

.NET

def RemoveFrom(self, registry: CadCommandRegistry) -> bool

Takes the commands and aliases CadPlugin.AddTo added out of a registry again; a command since replaced there is left.

ToString

.NET

def ToString(self) -> str