This shows you the differences between two versions of the page.
rhino:macroscriptsetup [2020/08/14] 127.0.0.1 external edit |
rhino:macroscriptsetup [2021/06/21] (current) dan |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======How to Set Up and Run Macros and Scripts in Rhino ====== | + | ======Integrating macros |
- | \\ | + | >// |
- | =====Creating a button or alias for your macro or script===== | + | =====Macros===== |
- | 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, look in the Help file. There’s a good explanation. | + | >// |
- | =====Use the macro editor to work out new macros===== | + | ===Using the macro editor to work out new macros=== |
- | The MacroEditor command opens a text editing window in which you can type macros and try them without the need to edit a button every time. The run button | + | 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 arrow button runs the macro. If there is anything |
- | {{: | + | ===Creating aliases or toolbar buttons to run your macros=== |
+ | The easiest way to save and run a macro is either with an alias or a new toolbar button. | ||
- | =====Paste your macro or script into the button or alias===== | + | **Alias creation** is essentially |
- | There are two ways to approach associating the macro or script to your button or alias. | + | |
- | The paste-in-button | + | * In Rhino, go to Options> |
+ | * In Windows, click the " | ||
+ | * In the left column, type the alias. | ||
+ | * In the right column next to your new alias name, type or paste in your macro. | ||
+ | * In Windows. click OK to save the alias. (Mac saves the alias as soon as you're done typing) | ||
+ | * Done. Now, when you type your alias at the command line, your macro will run. | ||
- | =====Linking to external scripts===== | + | **Toolbar |
- | To set up an external scripts folder: | + | |
- | To link your button or alias to an external script: | + | * For Windows |
+ | * For Mac Rhino, have a look at [[rhino:mac: | ||
- | \\ | + | Once you have created your new button, in the editor window, type or paste in your macro, save and close. |
- | ===Button editor showing pasted in macro and link to external script=== | + | ---- |
- | {{: | + | |
- | You can also paste an entire [[developer: | ||
- | < | + | =====Scripts===== |
- | ! -_Runscript ( | + | Scripts are actually small computer programs that can access Rhino core functions and thus allow you to do a much wider array of operations than macros. |
- | <Paste in | + | |
- | your entire | + | |
- | script here> | + | |
- | ) | + | |
- | </ | + | |
- | ===Button editor showing pasted in complete RhinoScript=== | + | >//For one-time or occasional use, you can simply save a script somewhere on your computer and then call it from inside Rhino using the **RunPythonScript** command (.py Python scripts, both platforms) or the **Runscript** command (.rvb Rhinoscripts, |
- | {{: | + | |
+ | ====Organizing your script collection==== | ||
+ | ===Storing your scripts in a specific location=== | ||
+ | |||
+ | Rhinoscripts or Python scripts //can// be directly pasted into custom toolbar buttons (see below), but this does not work with aliases. A good way to work around this is to place scripts externally in a folder with a link so that Rhino can find them when the command is run. Both toolbar buttons and aliases can link to external scripts. One advantage of this system is that all your scripts can be located in one spot so you can easily find and update them. | ||
+ | |||
+ | >//Rhino for Windows and Mac both provide default locations for storing scripts. The folders are hidden from the user by design, so here is how to locate them:// | ||
+ | |||
+ | **On the Windows platform**, the default scripts folder path is in the hidden **AppData** folder. | ||
+ | C: | ||
+ | You can get to it by clicking the Windows " | ||
+ | |||
+ | **On the Mac platform**, the default scripts folder path is located in the **~Library** folder, also hidden. | ||
+ | ~/ | ||
+ | | ||
+ | **For Mac Rhino 6.0 and later**, the version number has been added to the folder path like in Windows. | ||
+ | ~/ | ||
+ | | ||
+ | You can navigate to the ~Library folder by holding down the Alt key and pulling down the " | ||
+ | |||
+ | ===Helping Rhino find your stored scripts=== | ||
+ | **On Mac**, this is easy - the work has already been done for you - Mac Rhino already knows where the scripts folder is, so scripts located in that folder can be run very simply. | ||
+ | |||
+ | **On Windows**, it's a little more complicated, | ||
+ | |||
+ | **For Rhinoscript**, | ||
+ | **For Python scripts**, first open the script editor using the **EditPythonScript** command, then go to Tools> | ||
+ | |||
+ | >//Note that no matter where scripts are stored on your computer, they can always be run if you provide the **full path** to the script in your alias or button. | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ====Running scripts from aliases or toolbar buttons==== | ||
+ | |||
+ | **For aliases**, create them as described above in the first section... | ||
+ | Simply with the filename if you have set a search path - or you are on Mac and the scripts are in the default scripts folder: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Or with the full path if you haven' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | //(shown above: Windows)// | ||
+ | |||
+ | >//**Do not forget to enclose the file name/path in quotes!** \\ | ||
+ | If there are spaces in it and no quotes, the script will not be found!// | ||
+ | |||
+ | **For toolbar buttons** if you have created them: \\ | ||
+ | Open the button editor and use the same text as you would with aliases: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | You can also paste an entire script into a button. For that, start with the command \\ | ||
+ | **! -_RunScript** (for .rvb) or **! _-RunPythonScript** (for .py) \\ | ||
+ | followed by a space and an open parentheses. | ||
+ | |||
+ | {{: | ||
+ | //(shown above: Windows)// | ||
+ | |||
+ | >// | ||
+ | |||
+ | |||
+ | Last edit 29.08.19 - msh | ||