Creating Your First Toolbar/Button/Macro

Our kind user, Brian Lake, decided to share some of his knowledge with the rest of us, and in this tutorial he will be showing you some basics about macros, toolbars, and button creation.

Image 1

Image 1

The model used will be a model provided by Rhino in the Tutorial section.
(C:\Program Files\Rhinoceros 4.0\English\Tutorials\Camera-SLR.3dm)

Our object is going to be creating a custom toolbar with a custom button that will turn a “blueprint” preview on and off of our viewports.

Image 2

Image 2

You should already have your Command Window open. ALWAYS!
Your command window will provide you with just about everything that is going on in the Rhinoceros program. (Including the commands you will need to use to initiate macro commands.)

Next you’ll need to have your macro editor open.

Image 3

Image 3

As stated earlier every button/tool in Rhinoceros initiates these so called Commands in the Command window.
To test this out, go ahead and push the move button in your toolbar and watch the command window. Notice the _Move command which was initiated?
What does this mean? This means you can run Rhinoceros without ever having to click a button in your toolbars. (But the defeats the purpose of having easy to use buttons!)

Rhinoceros has been built to be very straightforward with commands such as Move, Delete, Rotate, , etc.. If you ever are unaware of a command you can simply initiate the tool however you would and see what the command window is using as the actual command. For this tutorial we will be using the and commands. Seems simple right? Simple but powerful!

No more wasting time, let’s get to the dirty work!
In our macro editor, let’s initate the grid command so we can control the properties of a grid(s).

Image 4

Image 4

Why did we use ! _Grid?

The ! Character will stop any current processes you may have running in Rhinoceros. This will keep you from accidentally running the macro when it shouldn’t be ran. You should always start your macros with the ! Character.

The _ right before Grid is a way of telling Rhinoceros to ignore the specific word Grid and use whichever word is identical in the current language of the current user. It’s always good practice to code this way, however, if you have no intention of sharing your macros then you may omit this while writing your macros.

Ok, so we’ve initiated the Grid command and now see several options we are able to change within the Command window. All we are going to do is type the commands we want to control exactly how you see them.

Image 5

Image 5

As our code is stating:

ShowGrid=No        We are telling the Grid option we don’t want the grid shown
ShowGridAxes=No        We are telling the Grid axis option we don’t want the grid shown
ShowWorldAxes=No    We are telling the World axis option we don’t want the grid shown
ApplyTo=All        This is telling the Grid command that we want these options applied to all of our viewports. (You can choose to have it apply to only specific viewports if you wish.)
Enter This command is doing exactly what would happen if you were to hit the enter/return key on your keyboard. In this case it’s submitting all of our changes and finishing the grid command.

All commands in the macro editor must be separated with a space so watch closely as so you don’t insert or miss a space where it is necessary.

Check it out! We have turned all of our grids and axes off in our viewports!

Image 6

Image 6

Let’s jump ahead and finish our macro!

Image 7

Image 7

One thing to pay attention to is the -GradientView command. We are using the – at the beginning because without it, the command editor will actually skip any of our input and by default turn on/off the GradientView ability.

As you’ll notice I’ve input all of the settings I wish to change while in the GradientView command and closing the command with the _Enter after I’ve changed any settings I felt necessary.
Your viewports should now look something similar to mine.

Image 8

Image 8

Congratulations, you’ve completed your very first macro!

“But wait a minute…. How do I save and use this macro by pressing a button?”
Have no fear my Rhinoceros minions!

Pages: 1 2

used 2 commands

,

One Response to “Creating Your First Toolbar/Button/Macro”

  1. alfredo says:

    excelt page!!!

Leave a Reply

You must be logged in to post a comment.