You are on page 1of 5

Weaving Component Tutorial for Generative Components

by Josh Mason
Place three 3D curves with points in the model Loft the curves to create a BSplineSurface. Place a point on the surface and replicate as
space. This can be done with a short cut by shown in previous examples. Place a panel on
creating a BSplineCurve byPoints then holding the point grid.
Ctrl and clicking in the model space.

The following in a component created in a previous examples, Component Canopy

Start a component by placing four points in Create two lines by points from opposite Create a point by centroid of set using the
space and creating a polygon by vertices. corners of the polygon. This becomes crucial vertices of the polygon as your input.
in generating the component. Ex: SetToFindCentroidFrom: shape01.Vertices
Ex: StartPoint: shape01.Vertices[0]
EndPoint: shape01.Vertices[2]

INPUTS

Place a direction by cross product using your This was a shortcut to create a graphVariable. If done properly, you’re symbolic model should
two lines and your centroid, then add a point Now change the length from the last point to look like this. This is important will inform your
by direction and length. Input Dist = 5 for the shape01.Area/Dist. The distance of the point component.
length. This creates a graphVariable Dist. will be relative to the size of the polygon.
To create a weave across the surface the
components need to populate above and
below the surface. To achieve this, we will
have to write a script that passes in distance
values that alternate positive and negative.

transaction script “Populate the components with a script”


{
’Holder’ contains the values of distance for
double holder = {};
every component. It must have the same
int direction = 1;
dimensions as the panel array
int magnitude = 5;

for (int i = 0; i < polygon01.Count; i++) Every new array within a double has to be
{ initialized if values are not immediately passed
into it.
holder[i] = {};
This equation returns 1 or -1 for every integer.
% is the remainder after the division of two
direction = i%2*-2+1; values (9 % 5 = 4)

for (int j = 0; j < polygon01[i].Count; j++) Put a positive or negative magnitude into each
{ element of the array.
holder[i][j] = direction*magnitude;

Change the positivity of the direction to invert


direction = -direction;
the next component
}
}
Create a global feature by placing a name in
quotes. Here we are passing in a double array
A_UEL_can temporaryComponentVariable = new A_UEL_can(“ScriptedComponent”); of panels (polygon01) with a matching double
temporaryComponentVariable.ByDefault(holder, polygon01); array of distances (holder) creating all of our
} alternating components at once.

Conclusion:
Note that the array now has a value for each
component so it is not as accessible. We could
use a GraphVariable instead of a magnitude
but this would require indirect contact with the
component. Additionally, creating alternative
weave patterns requires another transaction
script.
Create a BSplineCurve byPoints using Creating a copy using the Transpose of
ScriptedComponent.point11. This creates an ScriptedComponent.point11 gives the opposite
array of curves. weave direction.
Alternatively, we can create a component This pops up the scripting window with the GC statement builder
by Function thereby keeping the magnitude following useful buttons on the menu bar. This is very handy for the novice programmer.
accessible. To create a component by function, It sets out the construction of loops and
click here: Tab in/out Bookmarks conditional statements. To use, click on the
(I don’t use them)
relevant heading, input variables and hit
Comment/Uncomment return.

Function library, feature dictionary, file


locations, etc. Indispensable. Have a browse.

To create our component by function, in the


script window, type the following using the Input parameters - whereas before we had to declare the magnitude
statement builder where convenient. within the script, here it is an input. Note: you don’t actually have to
put the declaratives Polygon and double respectively. GC allows you
to be lazy and not declare types at function declarations however
function (Polygon panels, double magnitude) you will not get drop down menus later on in the script when you hit
{ full stop.

double holder = {}; As before, we need a double array to match the number of panels.
int direction = 1;
Try using the statement builder here and tabbing between the blue
for (int i = 0; i < panels.Count; i++) boxes that pop up.
{
holder[i] = {};

direction = (i % 2) * (-2) + 1;
As before.
for (int j = 0; j < panels[i].Count; j++)
{
holder[i][j] = direction*magnitude;
direction = -direction;
}
}
Here you are declaring that the component you are creating
A_UEL_can temporaryComponentVariable = new A_UEL_can(this); be assigned to the feature calling the function. This adds
temporaryComponentVariable.ByDefault(holder, panels); the components to the parent feature so the double array of
} components actually arrives as the first index of a triple array. If you
mouse-over a point you will see newcomponent[0][1][1].point13.

To create the new component as the double array, use this


this.ByDefault(holder, panels); alternative. Because the function doesn’t know what kind of feature
is calling it, you will not get a drop down menu after this.

FunctionArguments
Debugging
{polygon01, 5}
Add a ‘breakpoint;’ at any point in any script and you will get a debugging window where
Although it was not declared the function
you can watch variables and follow your script as it plays.
requires a double array for ‘panels’ and will
throw an error if one is not provided.
Alternatively, before activating a script whether as a feature by function or a script
transaction, go to Debug -> Manage Breakpoints. Here you can add breakpoints to
The magnitude, 5 in this case, can now be
scripts or features that will only execute when you hit Execute All.
changed easily from outside the script and in
later transactions without writing another script.
You can also right click on any feature’s properties and click ‘Watch This Property.’
We can create BSplineCurves on top of
the components as before or create a
BSplineCurve.ByFunction as follows:

Copy the entire script from before to a new Here, the component is created as temporary construction meaning
BSplineCurve.ByFunction. Replace ‘this. it is never put on screen. It is used purely as a scaffold with which
ByDefault(holder, panels); with we create our BSplineCurves.

A_UEL_can temporaryComponentVariable = new A_UEL_can(); As before, we use ‘this’ to refer to the parent feature. Since it is a
temporaryComponentVariable.ByDefault(holder, panels);v BSplineCurve we can use the ByPoints method. Note that although
there is not the typical drop down menu, we can operate on the ‘this’
this.ByPoints(temporaryComponentVariable.point11); placeholder as if it were a BSplineCurve (as illustrated by the ‘Color’
this.Color = 5; command).

As before the curves weave through the Using a variable for the magnitude, the Creating a copy of the previous curve by
polygons we’ve created. Symbolic Model is still considerably simplified function and using the Transpose of the
with the component not visible. polygons and the negative of the magnitude
variable, mag, we arrive at the weave above.

Conclusions

This example is meant to further demonstrate


the ‘component’ as a device for making local
decisions across a design surface. This
information is then used to construct an array
of continuous elements that respond to but are
not connected to the design surface.

The point of this exercise is to demonstrate


that the component is not necessarily
something you see. Additionally, while it
responds to a local condition, it can be used
to inform regional articulation and continuous
elements.

This example also attempts to exploit GC’s use


of arrays by compressing the Symbolic Model
and minimizing what is actually created with
temporary features.

You might also like