Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
fr:rhino:macroscriptsetup [2020/08/14]
127.0.0.1 external edit
— (current)
Line 1: Line 1:
-====== This page explains how to set up and run macros and scripts in Rhino ====== 
- 
-=====Creating a button or alias for your macro or script===== 
-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. 
- 
-=====Use 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 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. 
- 
-{{:legacy:en:MacroEditor.gif}} 
- 
-=====Paste your macro or script into the button or alias===== 
-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. 
- 
-=====Linking to external scripts===== 
-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 [[developer:rhinoscript|RhinoScript]] .rvb file use the command **LoadScript** **//Filename.rvb//** instead.  That’s all you need to do. 
- 
-===Button editor showing pasted in macro and link to external script=== 
-{{:legacy:en:EditToolbarButton.gif}} 
- 
-You can also paste an entire [[developer:rhinoscript|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 
- 
-  ) 
- 
-===Button editor showing pasted in complete Rhinoscript=== 
-{{:legacy:en:EditToolbarButton2.gif}} 
- 
- 
  
fr/rhino/macroscriptsetup.1597445311.txt.gz · Last modified: 2020/08/14 by 127.0.0.1