Writing the script

1. Open Rhino and then drag the Tools Toolbar scripting toolbar out into the Rhino workspace.
2. Click the your Notepad icon to open Notepad.
3. Then click the windows taskbar and then right mouse click choose Tile vertically, drag Rhino to the left to show more of its' workspace.

In the illustration above I created the rectangle and circle and then moved the circle to it's proper location, because these are the important parameters for my script.
I then open the command history window by pressing the F2 hotkey to see how Rhino processed the information.
I look for small switches in commands that I may need to be specific about. In this case there is the Diameter "d" switch or Radius "r" switch that I must address when using the circle command in a script.
I also look at the dimensions used to create the block and the numbers/values I used to move the circle.
There is also the cap option on the Extrude command that I need to be aware of.

Next mimicking the procedures that you view in Rhinos command history, you begin to write the script in notepad. The first step was drawing a rectangle 10 by 15 units, so that will be the first line of the commandscript. Notice in the commandhistory it says only Rectangle but if you shift Right mouse click over the rectangle icon to see what is written there you will see ! Rectangle. Remember the ! switch cancels all previous commands. In this case we want our Script to cancel all previous commands because you are creating a new model. The proper way is to write "! Rectangle" for the first line of the commandscript. You could easily cut and paste the syntax for rectangle right from the icon and then paste it into notepad as well to make sure that all the spelling is correct.

The first line of the script in notepad should read
! Rectangle

Notice that it is an apostrophe followed by a space then the word Rectangle. Test the first line of the script by highlighting the text and then copying it. In Rhino make sure the top viewport is maximized and click your commandpaste button. Rhino should prompt you for the next step in creating the rectangle, press the escape key to stop the command. This shows you that the first line was correct.

*Tip* Use command History to debug scripts
Here is how you debug a script or lines in a script. In notepad remove the space between the ! and the word Rectangle. Copy the text and commandpaste it into Rhino. Notice that nothing happens. Look at your command history to see what it says. Notice that it reports "unknown command !Rectangle". This way you know for sure where and on which commands your script are hanging on. In this case the fix is simple just add the space back in.

Continuing with the commandscript, you now need to enter the coordinates where the rectangle begins to be drawn from, in this case from 0,0,0. The shortcut for that in Rhino and in a commandscript is 0. We then know that the block is 10 units wide by 15 long.

Putting that information in the script we end up with the following lines:

! rectangle

Notice how I separated each action on a different line. You could write the script:
! rectangle 0 10,15.
However notice the ambiguity that this introduces. You need to make sure that there is a space between each succinct action because either a space the word enter or a new line acts like the user hitting the enter key as they carry out the command. How can you tell if the zero is part of the 10,15 unit settings or not? It's hard to tell. I highly recommend that you put each action on a separate line. It also makes the script easier to read and debug and lets the script flow in a linear fashion that mimics the activity that the Rhino command line makes when you work.

Copy the text from notepad and commandpaste it into Rhino. You should have a 10 by 15 unit rectangle drawn in the top viewport. See image. Delete the rectangle and continue with the script. If you have an error check the command history to see what it says.