COMPUTER
AIDED
ARCHITECTURAL DESIGN
Workshop 17 Notes,
Week of November 23 , 2015
COPY AND TRANSLATE OBJECTS TO 1D, 2D, AND 3D ARRAYS
Arrays of objects can be created within one, two or three vector directions. These workshop notes begin with a one dimensional array used to describe a staircase, and then faciltate a two dimensional array that copies columns into a planar grid, and a three dimensional array that creates a full floor to floor grid of columns.
PART 1: One Dimensional Staircase Array
1.1 Setup step and components in GH
Use Rhino's solid Box tool create a box that represents a single step at the dimension 3' x 11" x 7". In foot measurement units, this this equivalent of using the "Box" command with measurements 3' x 11/12' x 7/12'.
Next add a point on the forward lower-left and another point on upper-right corner of the step. These points will define a translation vector for copying the first step into the next step location in the stair.
Open Grasshopper and create components for the geometry of the step and the two points. That is, within the params tab, pull down the "Geometry" menu on the left side of the avaible tools, and select a "Geometry" component from the lower right-hand side.
Now add parameters the two point components. Label one "startPt" for the point at the lower left part of the stair, and the other "endPt". Also, add an int slider for number of copies with a minimum of 1 and a maximum of 100.
Right-mouse-click on the the "Geo" component and "set one geometry" to the stair. Similarly, in turn, right-mouse-click on the "startPt component ad set it to the point located on the lower left-hand corner point of the stair, and right-mouse-click on the "endPt" component and set it to the other point on the near upper right-hand side of the stair.
Save the Grasshopper script to the name stairway.gh. Go tot the "Math" tab within Grasshopper and add a Python component.
Right-click on the input variable "x' for the Python component, change it's name to Geo, and select the type hint as "ghdoc Object when geometry (rhinoscriptsyntax)"
Right-click on the input variable "y" for the Python component, change its name to "startPoint" and select the type hint as "Point3d".
Add a new input variable "endPoint" and select the type hint as "Point3d".
Add a new input variable "numCopies" and select the type hint as "Point3d".
Connect the component output ports to the corresponding Python script input ports
1.2 Creating the Python script.
The Python script for the stair may be conceived abstractly has having two primary functions. These are:
To begin creating the Python script, the general steps needed are placed n "pseudo code" following a similar scripting strategy that was used in the previous workshop.
Second, the implementation of the script contines with importing Rhino and rhinoscriptsyntax libraries which have been used throughout examples in the workshops. If it turns out that one of the libraries isn't needed then it can be deleted from the script. This is followed by creating the function "copyElement" identified in "Step1" of the pseudo code (see lines 5 through 11 below). Next, result of the function is set to the output variable "a" in line 25 below. This tests if a a single step can be copies before attempting to build the full staircase.
Third, the implementation of the script is fruther developed with creating the function "makeStairs" of step two (see lines 13 - 29 below). The key is to include a loop that establishes a new endPt component for each additional copy of the original step needed. The main work of stairway.gh is done inside the iterative loop which begins on line 18 below. Within the loop:
Once the loop is completed, the list of step objects are returned from the function on line 29 and assigned to the output vaiable "a" line 41. The output variable "a" in turn allows the end user to preview the steps within the Rhino view window.
PART 2: Two Dimensional Array
An object can copied in the x y plane through nesting one loop inside another. Here too the basic process can be first sketched through the use of pseudo code.
Place a vertical box of dimensions 0.5' x 0.5' x 8' and a point at the origin of the XYPlane as depicted in the figure below.
Open Grasshopper and setup parameters for "startPt", "Geo" similar to the case of Part 1, and:
Next, within the math tab create a Python component with input ports corresponding to the parameters above and make the connections:
Within the Python component, the Pseudo code is similar to that of Part 1 in that it subdivides into to primary functions (see step 1 and step 2 below):
Step 1 can use the same function "copyElement" that was used in Part 1 above. The Python script is thus modified as follows.
For step the function "makeArray" is added and contains an outer loop for the rows and an inner loop for the columns.
Similar to Part 1, the makeArray function returns a list of copied objects that are assigned to the output variable "a" in line 42 below.
For 2 rows and 2 columns, a preview of the Python script yields the following result.
Adjusting the sliders for 10 rows and10 columns, a preview of the Python script yields the following result.
However,
in the case of i = 0 and ii = 0, the first object is duplicated at its
original location. To avoid this one issue, a conditional "if" statment
is added the script in line 23. The statement
if (not ( i ==
0 and ii == 0) is true if and only if i does not equal 0 and ii does
not equal to 0. This cirumvents copying the object to its original
location.
The final script twoDimensionalArrayFinal.gh includes the correction in line 23 above and yields th following result:
PART 3: Three Dimensional Array
3.1 Create the Array
An object can copied in a three dimensional array nesting one loop inside another for the gound surface, then these two loops inside an additional loop to go from vertical level to vertical level. The logic is simply an extension of the case for the 2D array.
First new parameters for "numLevels" along the z-axis and for "height" between the levels is added to the original set of Python components.
The final script threeDimensionalArray.gh is completed as follows.
The script produces the following outcome.
3.2 Add an object to the Array
Note that if a new element is added to the original geometry file, it can be added interactively to the 3D array.
For example, place a simple box at the base of each column.
Next, right-click on the Geo parameter and choose the option "Manage Geometry collection".
Within the dialog box named "Generic geometry persistent data" that follows, select the "green" box icon, and then select the new element in the Rhino file.
Select the OK button within the "Generic geometry persistent data" dialog box, the the preview of the 3D array will appear as follows.
3.3 Finally, right mouse-button-click on the output variable "a" and select the "bake" object to add the previewed geometry to Rhino. The result will render as follows.