Command

References
public abstract class Command
Defines a base class for all commands. This class is abstract.

Constructors

Command

#
Default protected constructor. It only allows instantiation through sub-classing.
protected Command()

Properties

CommandContextHelpUrl

#
Gets the URL of the command contextual help. This is usually a location of a local CHM file.

The default implementation return an empty string.

protected virtual string CommandContextHelpUrl { get; }

EnglishName

#Since v5.0
Gets the name of the command. This method is abstract.
public abstract string EnglishName { get; }

HistoryReplayOnObjectAttributeChange

#Since v8.34
By default, object attribute changes do not trigger history replay. Set this property to true, typically in the command's constructor, if you want objects created with this command to trigger history replay when their attributes change.
public bool HistoryReplayOnObjectAttributeChange { get; set; }

Id

#Since v5.0
Gets the unique ID of this command. It is best to use a Guid attribute for each custom derived command class since this will keep the id consistent between sessions of Rhino GuidAttribute
public virtual Guid Id { get; }

LastCommandId

#Since v5.0
Gets the ID of the last commands.
public static Guid LastCommandId { get; }

LastCommandResult

#Since v5.0
Gets the result code of the last command.
public static Result LastCommandResult { get; }

LocalName

#Since v5.0
Gets the local name of the command.
public virtual string LocalName { get; }

PlugIn

#Since v5.0
Gets the plug-in where this commands is placed.
public PlugIn PlugIn { get; }

Settings

#Since v5.0
Gets the settings of the command.
public PersistentSettings Settings { get; }

Methods

DisplayHelp

#Since v5.0
Displays help for a command.
public static void DisplayHelp(
commandId
A command ID.
)

GetCommandContextHelpUrl

#Since v8.18
Returns a command's context help url.
public static string GetCommandContextHelpUrl(
commandId
A command ID.
)
The command's context url if provided.

GetCommandNames

#Since v5.0
Gets list of command names in Rhino. This list does not include Test, Alpha, or System commands.
public static string[] GetCommandNames(
english,
if true, retrieve the English name for every command. if false, retrieve the local name for every command.
loaded
if true, only get names of currently loaded commands. if false, get names of all registered (may not be currently loaded) commands.
)
An array instance with command names. This array could be empty, but not null.

GetCommandStack

#Since v5.0
Determines if Rhino is currently running a command. Because Rhino allow for transparent commands (commands that can be run from inside of other commands), this method returns the total ids of active commands.
public static Guid[] GetCommandStack()
Ids of running commands or null if no commands are currently running. The "active" command is at the end of this list.

GetCommandStyle

#Since v9.0
Returns a command's style flags.
public static Style GetCommandStyle(
commandId
A command ID.
)
The command's style flags, or Style.None if the command is not found.

GetMostRecentCommands

#Since v5.0
Gets an array of most recent command descriptions.
public static MostRecentCommandDescription[] GetMostRecentCommands()
An array of command descriptions.

InCommand

#Since v5.0
Determines if Rhino is currently running a command.
public static bool InCommand()
true if a command is currently running, false if no commands are currently running.

InScriptRunnerCommand

#Since v5.0
This is a low level tool to determine if Rhino is currently running a script running command like "ReadCommandFile" or the RhinoScript plug-in's "RunScript".
public static bool InScriptRunnerCommand()
true if a script running command is active.

IsCommand

#Since v5.0
Determines is a string is a command.
public static bool IsCommand(
name
A string.
)
true if the string is a command.

IsValidCommandName

#Since v5.0
Determines if a string is a valid command name.
public static bool IsValidCommandName(
name
A string.
)
true if the string is a valid command name.

LookupCommandId

#Since v5.0
Returns the ID of a command.
public static Guid LookupCommandId(
name,
The name of the command.
searchForEnglishName
true if the name is to searched in English. This ensures that a '_' is prepended to the name.
)
An of the command, or Guid.Empty on error.

LookupCommandName

#Since v5.0
Returns the command name given a command ID.
public static string LookupCommandName(
commandId,
A command ID.
englishName
true if the requested command is in English.
)
The command name, or null on error.

OnHelp

#
Is called when the user needs assistance with this command.
protected virtual void OnHelp()

ReplayHistory

#
Repeats an operation of a command.

In order to make this function work, you will likely need to grab the Result property that gives the list of input objects. Then, you will be able to replace these inputs by using one of the UpdateToX() methods of the ReplayHistoryResult.

You should NOT use any document AddX() or ReplaceX() functions, as they will break history.

protected virtual bool ReplayHistory(
replayData
The replay history information.
)
true if the operation succeeded.

The default implementation always returns false.

RunCommand

#
Executes the command.
protected abstract Result RunCommand(
doc,
The current document.
mode
The command running mode.
)
The command result code.

RunProxyCommand

#Since v6.13
Execute some code as if it were running in a command
public static void RunProxyCommand(
commandCallback,
doc,
data
optional extra data to pass to callback
)

Events

BeginCommand

#Since v5.0
Called just before command.RunCommand().
public static event EventHandler<CommandEventArgs> BeginCommand

EndCommand

#Since v5.0
Called immediately after command.RunCommand().
public static event EventHandler<CommandEventArgs> EndCommand

UndoRedo

#Since v5.0
Used to monitor Rhino's built in undo/redo support.
public static event EventHandler<UndoRedoEventArgs> UndoRedo