Site Tools


Differences

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

Link to this comparison view

Next revision
Previous revision
rhino:basicmacros [2020/08/14]
127.0.0.1 external edit
rhino:basicmacros [2025/03/20] (current)
dan [The tools you need]
Line 5: Line 5:
 You can create **macros** in Rhino to automate many tasks, customize your commands, and improve your workflow. You can create **macros** in Rhino to automate many tasks, customize your commands, and improve your workflow.
  
-There may be some confusion about the use of the term “scripting”.  It has been used to describe both the process of writing macros - what this section is about - as well as writing more sophisticated scripts in either [[developer:rhinoscript|RhinoScript]], [[https://developer.rhino3d.com/guides/rhinopython/|Python]], or other programming languages.  +There may be some confusion about the use of the term “scripting”.  It has been used to describe both the process of writing macros - what this section is about - as well as writing more sophisticated scripts in either [[https://developer.rhino3d.com/guides/rhinoscript/|RhinoScript]], [[https://developer.rhino3d.com/guides/rhinopython/|Python]], or other programming languages.  
  
 //The two things are actually very different.// Writing functions in RhinoScript, Python or other programming languages is a lot more complex than creating macros, and requires some programming knowledge and skills.  //We don't cover that here.// //The two things are actually very different.// Writing functions in RhinoScript, Python or other programming languages is a lot more complex than creating macros, and requires some programming knowledge and skills.  //We don't cover that here.//
Line 16: Line 16:
   * The **Rhino Help file** -  lists all Rhino commands and their sub-options. This is your most important reference.  Pressing F1 (Windows) or the :?: toolbar button (Mac) will get you to the online help.   * The **Rhino Help file** -  lists all Rhino commands and their sub-options. This is your most important reference.  Pressing F1 (Windows) or the :?: toolbar button (Mac) will get you to the online help.
   * The Rhino **MacroEditor**, a built-in interface for creating and testing your macros.   * The Rhino **MacroEditor**, a built-in interface for creating and testing your macros.
-  * An understanding of how to add your macros to your workflow in the form of aliases or toolbar buttons (explained [[developer:macroscriptsetup|here]])+  * An understanding of how to add your macros to your workflow in the form of aliases or toolbar buttons (explained [[https://developer.rhino3d.com/guides/general/creating-command-macros/|here]])
 =====You've already used a macro or two...===== =====You've already used a macro or two...=====
 First, if you are a user of Rhino, you are already a macro user even though you may not know it.  Many of the commands in Rhino are already “macroed” for you. When you click a toolbar button or call a command from the menu, it is often a preset macro.  For example, the toolbar button **Extrude Closed Planar Curve** from the "Solid" toolbar has the following macro: First, if you are a user of Rhino, you are already a macro user even though you may not know it.  Many of the commands in Rhino are already “macroed” for you. When you click a toolbar button or call a command from the menu, it is often a preset macro.  For example, the toolbar button **Extrude Closed Planar Curve** from the "Solid" toolbar has the following macro:
Line 63: Line 63:
   ! _Box _Center _Pause r5,5 _Enter   ! _Box _Center _Pause r5,5 _Enter
 Now that the macro is running, [[rhino:macroscriptsetup|make a new toolbar button]] and paste the macro in. Give it a recognizable name, like “10x10x10 bottom centered box”.  Note, once the macro is executed, right-clicking repeats the whole sequence of this macro, so you can use it many times in a row without clicking the button every time. Now that the macro is running, [[rhino:macroscriptsetup|make a new toolbar button]] and paste the macro in. Give it a recognizable name, like “10x10x10 bottom centered box”.  Note, once the macro is executed, right-clicking repeats the whole sequence of this macro, so you can use it many times in a row without clicking the button every time.
 +
 +> //Note on the Pause command://   In earlier versions of Rhino, for some command macros it was necessary to use one Pause for each screen pick needed.  This made it difficult to make macros for commands that had an indeterminate number of screen picks.  Much of that has been fixed in the latest versions, however there are still some exceptions.  For these cases, there is now the Multipause command (V6 and later), which basically allows the user to make as many picks as needed without having to write multiple Pause commands in the macro.
 +
 +For example the macro below
 +
 +  ! _Polyline _Pause _SelLast
 +
 +will work fine to make the polyline, but it will not be selected at the end.  Why?  Because the single Pause is 'eaten' by the first pick in the polyline, and thus the SelLast command gets executed just after the first pick while we're still making the polyline - and therefore does nothing.  The single pause //does// allow you to finish the polyline with as many points as you want, but there is no longer a SelLast to be run at the end of it - because it ran already and failed.  
 +
 +However, the following macro
 +
 +  ! _Polyline _Multipause _SelLast
 +  
 +works including selecting the polyline at the end because the Multipause includes //all// the picks for the polyline, allowing the SelLast to be executed and work at the end.
  
 =====OK, let’s get a bit more complicated…===== =====OK, let’s get a bit more complicated…=====
rhino/basicmacros.1597445311.txt.gz · Last modified: 2020/08/14 by 127.0.0.1