All Rhino commands can be used in command macros. Command macros can be run by typing the command at the command prompt, from toolbar buttons, shortcut keys, command aliases, from the ReadCommandFile command, or using the Paste command into Rhino's command stream.
Write command macros just as you would type the command sequence at the command line. A space between characters or a new line act like pressing Enter at the command line.
Special Characters | Meaning in macro |
---|---|
* |
Causes the command to repeat automatically without pressing Enter to restart. |
! |
Cancels the previous command. An exclamation point (!) and a space in the beginning of a macro cancels any previous command. At other locations, it cancels the macro. If necessary, the exclamation point can be used at the end of the macro. |
_ |
Runs command as English command name. Rhino can be localized in many languages. The non-English versions will have commands, prompts, command options, dialog boxes, menus, etc., translated into their respective languages. English commands will not work in these versions. For scripts written in English to work on all computers (regardless of the language of Rhino), the scripts need to force Rhino to interpret all commands as English command names. For example: In the English version of Rhino, the following macro works: Circle 3Point 0,0,0 1,1,0 0,3,0 But in the French version of Rhino, this won't work. Instead you need one of these macros: Cercle 3Point 0,0,0 1,1,0 0,3,0 To make sure macros work worldwide, write them in English and put _ in front of all command names and options. |
- |
Suppress dialog box. All commands can be made into macros at the command line (even commands that have dialog boxes by default). To suppress the dialog box and use command-line options, prefix the command name with a hyphen (-). |
' |
The next command is a nestable command. View and construction plane manipulation and object snaps are nestable. Geometry creation commands are not nestable. One-shot object snaps and sub-object picking filters are automatically nestable and do not require an apostrophe. |
/ |
If the first character in a toolbar macro is not "!" and the last character is" /", the script runs on the command line without Enter, so more information can be added. This feature is useful for building a command string out of parts like digits, decimal points, angles (such as "<45") that are on buttons, making a "numeric keypad" on the screen. |
~ |
Suppresses command options for clutter free command feedback. The options still work as usual. |
; (semicolon) |
Comment. Lines beginning with a semicolon (;) are not part of the macro, but let you document the macro or try alternative input. For example: ; This is a test macro |
:: (double colon) |
Layer nesting is indicated by a double colon - "::" between layer names. In the -Layer command, adding a new layer nested under Layer 01 use a macro like this: ! _-Layer New "Layer 01:: New Layer" Enter |
This macro creates a circle centered at 5,5 with a radius of 10:
! _-Circle 5,5 10
The spaces between the entries are the same places you would press Enter when typing the command by hand.
This macro starts the Move command, but makes sure no objects are selected before asking you to select objects to move:
! _SelNone _Move
This macro creates a set of three points, selects them all, and fits a polyline through the points:
! _SelAll _Points _Pause _Pause _Pause _Enter _Invert _CurveThroughPt _EnterEnd
How this script works:
! _SelAll |
Cancels all previous commands and selects all the objects currently in the model. |
_Points |
Runs the Points command. |
_Pause _Pause _Pause |
Allows picking three point locations. |
_Enter |
Simulates pressing Enter, which stops the creation of point objects. |
_Invert |
Inverts the selection. All visible objects in the scene were selected at the beginning of the script, so after Invert only the newly created point objects are selected. |
_CurveThroughPt |
Creates a polyline through the point objects. |
_EnterEnd |
Completes the command. |
! -_Rebuild _Pause _Points=10 _Degree=3 _Enter
Select a curve, then run this macro. All options will be set by the macro.
Pause |
Stops for user input in a macro. Example: ! _Circle _Pause 50 This macro asks for a point and then draws a circle with a 50 unit radius centered there. |
MultiPause |
Stops a script for the duration of multiple selections, for example in Join, Polyline, and FilletEdge. |
Enter |
Simulates pressing Enter inside a macro. This command does not repeat the previous command like pressing Enter does. |
EnterEnd |
Completes the command. |
SetRedrawOff |
Prevents screen redraw, construction plane or camera changes during macros. |
SetRedrawOn |
Turns screen redraw back on after SetRedrawOff. |
NoEcho |
Turns off echoing of macro commands to the command history window. |
Echo |
Turns on echoing of macro commands to the command history window. |
If you do not know what to type in a macro, run the hyphenated version of the command. Highlight and copy the command sequence and paste it into your macro text as a starting point.
Toolbar | Menu |
---|---|
|
Tools Commands > Macro Editor |
The MacroEditor command opens an edit window for macro creation and testing.
Macro Editor panel
Toolbar | Menu |
---|---|
|
Tools Commands > Read from File |
The ReadCommandFile command reads and executes a command macro from a text file.
Make a text file like the following example that has commands for creating all your curves in it, and then create the curves all at once with ReadCommandFile.
! _interpcrv
23,5,0
23.2,5,0
23.7,5.2,1
_Enter
_interpcrv
26.1,4.9,1.1
26.8,4.9,1.0
27.1,4.8,0.9
_Enter
etc&.
Toolbar | Menu |
---|---|
|
|
The Echo command turns on echoing of macro commands to the command history window.
To turn echoing off, use the NoEcho command.
Toolbar | Menu |
---|---|
|
|
The NoEcho command turns off display of macro commands in the command history window.
NoEcho or _NoEcho needs to be the very first word in the macro for it to work properly. Everything, including the exclamation point should follow, separated by a single space.
Toolbar | Menu |
---|---|
|
|
The Enter command functions as pressing Enter for use in scripts or toolbar button programming.
This script sets a construction plane by three picked points:
'_CPlane _3Point
_Pause _Pause _Pause _Enter
The Enter command does not repeat the previous command like pressing the Enter key does.
Toolbar | Menu |
---|---|
|
|
The EnterEnd command functions as pressing the Enter key to complete a command string for use in macros or toolbar button programming.
EnterEnd is handy when a command is deep, in terms of command options such as Options or DocumentProperties, and you want to exit after one of these without counting how many Enters you need to get back to a blank command prompt. For example:
! _-DocumentProperties _Mesh _Custom _MaxEdgeSrf .01
would require at least two or three enters to exit the command. With EnterEnd, the command exits as soon as you want it to.
! _-DocumentProperties _Mesh _Custom _MaxEdgeSrf .01 _EnterEnd
Toolbar | Menu |
---|---|
|
|
The Pause command stops a macro for user input.
This macro asks for a point and then draws a circle with a 50 unit radius centered there.
! _Circle _Pause 50
Toolbar | Menu |
---|---|
|
|
The MultiPause command stops a macro for user input.
This macro asks for objects to join.
! _Join _MultiPause
The Run command runs another application from inside Rhino.
Toolbar | Menu |
---|---|
|
|
The SetRedrawOff command disables screen redraw, construction plane, or camera changes during scripts.
Toolbar | Menu |
---|---|
|
|
The SetRedrawOn command enables screen redraw, construction plane, or camera changes during scripts.
For more information on Rhino-specific scripting, see: http://wiki.mcneel.com/rhino/basicmacros.
Toolbar | Menu |
---|---|
|
Tools Python Script > Run |
The RunPythonScript command runs a Python script.
For the on-line Rhino.Python programmers reference, see: http://developer.rhino3d.com/guides/rhinopython/.
Forces the python engine to re-initialize. This is only useful while python scripts that span multiple files are being written and tested.
The EditPythonScript command edits a Python script.
For more information on Rhino-specific scripting, see: http://wiki.mcneel.com/developer/python.
Rhino for Mac © 2010-2017 Robert McNeel & Associates. 24-Oct-2017