Table of Contents

CadRibbonButton

from OpenCAD2D.Plugins import CadRibbonButton

class CadRibbonButton(CadRibbonItem) ยท CadRibbonButton in the .NET reference

A button that starts a command, as a button of the presenter's own ribbon does, or runs a callback of the plugin at once on the window's thread.

Constructors

__init__

.NET

def __init__(self, text: str, run: System.Action[CadPluginContext]) -> None

Makes a button that runs a callback at once, on the window's thread.

def __init__(self, text: str, command: str) -> None

Makes a button that starts a command: a command running is cancelled first, as AutoCAD's ^C^C is.

Properties and fields

CanRun

.NET

@property
def CanRun(self) -> System.Func[CadPluginContext, bool] | None
@CanRun.setter
def CanRun(self, value: System.Func[CadPluginContext, bool] | None) -> None

Gets or sets whether the button is on, asked when the window asks its commands again (the selection, the drawing or a command changes). Null, until set: a button that starts a command or runs a macro is on while a drawing is open, one that runs a callback always. A predicate that throws gives false.

Command

.NET

@property
def Command(self) -> str | None

Gets the command the button starts; null for a button that runs a callback or a macro.

Macro

.NET

@property
def Macro(self) -> str | None

Gets the macro the button runs; null for a button that starts a command or runs a callback.

Run

.NET

@property
def Run(self) -> System.Action[CadPluginContext] | None

Gets the callback the button runs; null for a button that starts a command or runs a macro.

Methods

FromMacro

.NET

@staticmethod
def FromMacro(text: str, macro: str) -> CadRibbonButton

Makes a button that runs a macro as AutoCAD's CUI buttons do: ^C cancels the command running, ;, a space and ^M are Enter, \ waits for the user's answer, _ and . are as typed, and an expression in parentheses is AutoLISP. "^C^C_CIRCLE;0,0;\" starts CIRCLE at 0,0 and waits for the radius. A macro that uses * to repeat, $M= or another ^ pair than C, M and P is refused where the button is pressed, with a line that says so. A plugin that uses it states [assembly: CadPluginApi("1.2")].