This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
developer:macroscriptsetup [2021/01/08] mitch_heynick [Organizing your script collection] |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Integrating macros and scripts into your workspace====== | ||
- | |||
- | >// | ||
- | |||
- | =====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 out without the need to edit a button every time. The arrow button runs the macro. If there is anything selected in the editor, it runs the just the selected part, otherwise it runs the whole macro. When the macro runs to your satisfaction, | ||
- | |||
- | ===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. | ||
- | |||
- | **Alias creation** is essentially the same on either Mac or Windows: | ||
- | |||
- | * 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. | ||
- | |||
- | **Toolbar button creation and editing** is relatively simple in Windows Rhino. \\ It is somewhat more complicated in Mac Rhino. | ||
- | |||
- | * For Windows Rhino, there are good explanations in the [[http:// | ||
- | * For Mac Rhino, have a look at [[rhino: | ||
- | |||
- | Once you have created your new button, in the editor window, type or paste in your macro, save and close. | ||
- | |||
- | ---- | ||
- | |||
- | |||
- | =====Scripts===== | ||
- | 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. | ||
- | |||
- | >//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 | ||
- | |||