The simplest way to save and run your macro is from a toolbar button or alias. If you don’t know how to make a new toolbar button or alias, have a look in the Help file, there’s a good explanation. Once you have your new button (or have chosen to edit an existing one), open the editor by shift-right clicking on the button. For an alias, you will do the same thing, but instead of creating a new button, go into Options > Aliases and use the New button to create a new alias.
The MacroEditor command opens a text editing window in which you can type macros and try them out without the need to edit a button every time. The run button on the lower edge of the editor runs the macro, of if there is selected text, it runs the selected text. When it all runs to your satisfaction, copy and paste the macro to a toolbar button.
Now, there are two ways to approach associating the macro or script to your button or alias. First and simplest is to just copy/paste the whole thing into the left or right button box (or in the alias box). The advantage of the button method is that it is “portable”, that is if you copy or export the button to another installation the macro goes with it. Once the test is pasted in, click OK to exit the button editor, and you’re ready to go!
The paste-in-button (or alias) method is fine for macros of Rhino commands and shorter, smaller scripts, but it gets a bit unwieldy to edit if there is a great deal of text. For larger scripts, some people like to place them externally in a folder with a “link” so that Rhino can find them. Both toolbar buttons and aliases can link to external scripts. One advantage of this system is that all scripts are located in one spot so you can easily find and update them. The problem here is that if you copy your button or workspace for use somewhere else, you have to remember to bring the script(s) with it.
To set up an external scripts folder: Find a logical place to create your folder. This may either in the Rhino/system folder or some other common place. Open the Options dialog, and navigate to the Files tab. In the “file search paths” box, click the new button and then the little … button and browse to the location of the scripts folder, then click OK. Exit the options dialog. Rhino will now go looking for scripts in this folder.
To link your button or alias to an external script: The syntax used will depend on the type of script. If it is a simple text file with normal Rhino commands (like a long macro), you will need to use the command ReadCommandFile Filename.txt Substitute the name of your text file for Filename.txt. Paste that string into the left or right button box and you’re good to go. To run a RhinoScript .rvb file use the command LoadScript Filename.rvb instead. That’s all you need to do.
You can also paste an entire RhinoScript into a button, for that, it needs to start with the command RunScript (not LoadScript) followed by a space and an open parentheses. At the end of the script you need a close parentheses.
! -_Runscript (
Paste in your entire script here