CommandDefinition
A command a plugin adds to Modlumi’s menus. See PluginContext.registerCommand.
Properties
Section titled “Properties”contextMenu?
Section titled “contextMenu?”
optionalcontextMenu?:boolean
Also list the command in the viewport’s right-click menu while something is selected.
optionalicon?:string
An SVG file in the plugin folder, such as "icons/stairs.svg", drawn on the toolbar.
It is drawn as a single-color mask in the toolbar’s colors, so only the opacity of its
shapes counts. Draw on a 24-unit square with 1.5-unit strokes to match Modlumi’s icons.
Files up to 256 KiB; a missing or unreadable icon throws TypeError.
id:
string
Identifies the command within its plugin: letters, digits, dots, dashes or underscores.
shortcut?
Section titled “shortcut?”
optionalshortcut?:string
A keyboard shortcut, such as "Ctrl+Shift+K": Ctrl, Alt or Shift with a letter, digit
or F1 to F12. Letters and digits need Ctrl or Alt, because plain keys choose tools and
type measurements. Ctrl is Cmd on macOS. A shortcut that Modlumi or another plugin
already uses is dropped and logged; one with the wrong form throws TypeError.
optionaltip?:string
One sentence about what the command does, shown as its tooltip.
title:
string
The menu entry’s text, in title case, such as "Select Coplanar Faces".
toolbar?
Section titled “toolbar?”
optionaltoolbar?:boolean
Also show the command as a toolbar button, in a group for the plugin. Needs an icon.
optionalwhen?:"always"|"selection"
When the command can run: "always" (the default), or only while something is
selected ("selection"). Unavailable commands are shown disabled.
Methods
Section titled “Methods”isChecked()?
Section titled “isChecked()?”
optionalisChecked():boolean
Shows the command with a check mark while this returns true, for commands that
toggle something. Asked at the same times as CommandDefinition.isEnabled.
Returns
Section titled “Returns”boolean
isEnabled()?
Section titled “isEnabled()?”
optionalisEnabled():boolean
Whether the command can run now, beyond when. Unavailable commands are shown
disabled. Modlumi asks after the plugin activates, after each of its commands, and
after the model, selection, active context or document changes, so base the answer on
those. It must return synchronously and only read, like a change listener; a command
whose isEnabled throws is disabled.
Returns
Section titled “Returns”boolean
run():
void|Promise<void>
Runs the command. Edit the model inside Model.operation, so each run is one undo step. Errors are shown to the user and logged.
Returns
Section titled “Returns”void | Promise<void>