Binary Branching using Macro

by Tuğrul Yazar | April 15, 2013 13:08

2013_04_15-branch

Today’s design computing class was about fractals. In Rhino, writing macro statements are very easy to learn as it just mimics your behaviors in a sequential text. There are a few syntactic rules that we should know. First, you should watch the command line carefully to understand the steps of your design process. Each command in Rhino requires different inputs from the user. In macro, you may enter these values or tell the macro to ask the user by typing “_pause”. Blank spaces work as if you hit enter. Below is one of the examples we’ve discussed in class. It is running from the first line step by step down until the end. I’ll explain each step.

! ; fractal binary branching
_line 0,0,0 _pause
_sellast
_divide split=yes 2 _enter
_sellast
_arraypolar 0,0,0 3 360 _enter

; As there is not loop in macro
; copy four below rows again and again
; to enable feedback in the fractal tree

_selnone
_divide _pause split=yes 2 _enter
_sellast
_arraypolar _pause _pause 3 360 _enter

The first line, “!” is used to cancel any command that might be running when the macro starts. It is important because you can run a macro while another command is running in Rhino. “;” represents the start of a comment that should not be treated as a command. It is important to take notes on your macros in order to make them understandable. The next line starts with the macro commands. “_” at every command makes sure that you can run this command in any language version of Rhino. It now sends “_line” to the command line and hits enter by typing a blank space after it. Rhino is asking for the first coordinate of the line. “0,0,0” feeds this input automatically. Please be careful about “,”s, and “.”s in Rhino. “,” is always used in coordinates in the form of x,y, and z. While “.” is used in digits such as, “0.5” which means 1/2. After sending the first coordinate and hitting enter by a blank space, Rhino now asks for the second point. At this time, a macro lets the user define a point as usual by entering “_pause” there. Macro just pauses and waits for the input to be completed by the user. After this entry, I chose to continue from the next line because this makes the macro more readable. Note that getting to the next line is also hits “enter” in Rhino. “_sellast” is in fact a Rhino command we never use normally. It selects the output of the last command. The macro continues by sending the “_divide” command and changing a parameter of it. As you see, macro directly resembles the way you use command line inputs in a modeling process. No conditional statements or loops, in fact, nothing algorithmic here. However, you may use CTRL+C and CTRL+V to enable a kind of loop, making a part of the macro seemingly run recursively.

_fractal halfs

Source URL: https://www.designcoding.net/binary-branching-using-macro/