Attractors

From TOI-Pedia

Introduction

LEVEL: ADVANCED
Expected Time: 90 min
Possible result of this tutorial

This tutorial will cover the basic understanding of use of attractors in Grasshopper and will explain this by an example of a parametric componenten system that relates to an attractor. The design for this tutorial will be a simple canopy that will be populated by components. The components will have openings that are parametrically linked with a point that represents the sun.

The tutorial consists of two parts:

  • A basic example of 2D attractor
  • A design for an attractor canopy


Attractors

Using a curve as an attractor to define the radius of a grid of circles .

Attractors in parametric design can have multiple applications. They can be used in pattern design, but maybe more interesting is the application in performative design. For instance optimizing a facade to certain performance towards the sun. The example in the right image of this text is showing a curve attractor that defines the radius of a grid of circles. We will now very quickly go trough the steps that were undertaken to generate the result of this image at the right before we start our design.

Create a hexagonal grid

Create a hexagonal pattern using the respective component. Define the X and Y size using a numerical input.

  • Add a Hexagonal component to the canvas Vector » Grid » Hexagonal
  • Define the X and Y size with a Number Slider Params » Input » Number Slider


Set one curve in the hexagonal grid

Draw a curve in the hexagonal grid. The curve may intersect with the boundary of the grid. Set the curve to a curve parameter in the Grasshopper script

  • Draw a curve through the grid in Rhino
  • Add a Curve parameter to the canvas Params » Geometry » Curve
  • Set the curve to the parameter RMB on curve parameter » Set one curve


Find the Distance between curve and hexagon centers

Now we want to find the distance between the hexagon centers and the closest point on the curve. This can be easily done using the Curve Closest Point component.

  • Find the distance between the curve and the hexagon centers Curve » Analysis » Curve Closest Point


Remap the distances

Next, we want to remap the available distance values to another range. Since we have done that several times already, we will not explain this extensively. Make sure you first flatten the distance output! If you are having trouble understanding the remapping, take a look at Tutorial 12.

  • Flatten the distance output
  • Find the bounds of the distance values List » Domain » Bounds
  • Remap the values List » Domain » Remap Numbers
  • Define the Target domain using a Construct Domain component List » Domain » Construct Domain


Create circles in the hexagons
Result of this script

Based on the remapped distances, we create circles with the hexagon centers as origin. The radius is defined by the remapped distance. Make sure you flatten the Plane input.

  • Add a circle component to the canvas Curve » Primitive » Circle
  • Flatten the Plane input and connect the hexagon center points
  • Define the Radius with the remapped numbers


Extrude the circles

To make the result a bit more visible in 3D, we can of course also extrude the circles based on their distance to the curve. One method could be to remap the numbers again, but in this case, we will use a simple multiplication and a Z Unit vector to define the height.

  • Connect a Unit Z vector to the Mapped output Vector » Vector » Unit Z
  • Multiply the Unit Z vector with a factor Math » Operators » Multiplication
  • Extrude the circles using the Multiplication output as Direction Surface » Freeform » Extrude


Cap the cylinders

Finally, you will have to cap the cylinders.

  • Cap the cylinder holes Surface » Util » Cap Holes


Result of the script

The result is a cylindrical pattern in which the size of a cylinder is an expression of the distance to the curve.

As alternative, you could also create a script where cylinders are removed if they are lower than a certain distance limit. This would lead to the following adjustments.

Alternative script


Alternative result

Now your final model looks like the following image.

You now now have a basic example of an attractor in Grasshopper. The design of this tutorial will use a slightly different logic but will also show an other example of the application of attractors in Grasshopper.

The Design

An attractor based canopy

In this tutorial we will create a simple canopy that will be populated with components that are related to a point in the air that represents the sun. The shading components will point towards the sun but will not allow direct sunlight into the canopy.

Building the grasshopper model

Step 1 - Creating the canopy with openings

Set the base surface in Rhino

First we need to create a basic shape for the canopy. It doesn’t really matter how it looks like, but you can take the right picture as reference. One method could be to use the Rhino Sweep1 command. Based on one center curve and two section curves, you can create a surface like the image on the right. Next, set the surface on a Surface parameter.

  • Create a surface in Rhino
  • Set the Rhino surface to a Grasshopper surface parameter Params » Geometry » Surface


The script of Populate Surface tutorial

Now we need to divide the surface in triangular openings, which will be used for the shading component in a later stage. Therefore, we can use the first part of Tutorial 17 - Populate Surface. In the right image, you can see the script. The output of the script is the stage where the triangles on the surface are created using the polyline component.


The current stage of the model

Your models should now look like the following image.

Step 2 - Create the shading component base

The steps in the creation of the components.

The shading component will be created as you can see in the following illustration.

  • 1. We use the triangles of the surface as base.
  • 2. The top and bottom of the shading surface is reshaped to a curve, perpendicular to the surface normal, based on an attractor point.
  • 3. The side edge of the triangles is lofted to the new created curves
  • 4. All shading components are implemented into the roof


Retrieve the top/bottom and sides of the triangles

First we need to deconstruct the triangles in faces, edges and vertices using the Deconstruct Brep component. After that we use a list item component to find the top and edge of the triangle. In most cases you can use the Index input to 0. We will also need the side edges in a later stage, so it can be helpful to click on the +1 icon, to also extract that edge.

  • Deconstruct the polylines Surface » Analysis » Deconstruct Brep
  • Find the top and bottom edge of the shading component using a List item Sets » List » List Item
  • Also extract the side edges for a later stage

If you are not able to find the top and bottom edge of the triangles using Index 0, try another value for the Index input.

Find the middle points of the top/bottom edges

Now we find the middle of the top and bottom shading edge, using the Curve Middle component.

  • Find the Curve Middle for the top and bottom edge Curve » Analysis » Curve Middle


Step 3 - Creating the attractor

Create an attractor point

In this tutorial we will use a point as attractor object. This point could represent the sun for example, to define the direction of the shading system. First create a point in Rhino, preferably above your canopy surface, and set it to a Grasshopper Point parameter.

  • Create a point in Rhino
  • Set it to a Grasshopper Point Parameter Params » Geometry » Point


Lines between openings and attractor point

To visualize the attractor, we create a line between the Curve Middle Points from the previous step, with our attractor.

  • Create a line between the Curve Middles and the attractor point Curve » Primitive » Line


A point on the attractor lines

Now we find a point on the line which will define the height and location of the canopy shading components. One method to do this, is to use the Point On Curve component.

  • Find a point on the lines to the attractor using the Point On Curve component Curve » Analysis » Point On Curve


Find the start and end points of the triangle botoom/top

As described in the step 2, we need to create a curve between the original top and bottom edge of the shading component, and the point on the attractor line. First we find the end points of the top and bottom edge.

  • Find the Start and End point of the top and bottom edge of the shading components Curve » Analysis » End Points


Merge the points

Now we merge the points in the correct order: first the start, then the Point on Curve, and finally the end.

  • Merge the points for the curve Sets » Tree » Merge

The merge component can be useful to make sure you are using the right order to create some geometry. Only holding the shift-button to connect some wires to an input, can lead to an incorrect order of data an lead to unexpected results.

Create an interpolated curve from the points

Finally we interpolate the points using the Interpolate Component.

  • Interpolate the merged points Curve » Spline » Interpolate


The curves pulled to the attractor

Your model should now look like the following image. When you change the location of the attractor point, the curves top should move to another location. Changing the Point On Curve slider defines the height of the canopy shading components.

Step 4 - Lofting the Curves

Flip the side curves

Now we want to create a surface between the shading curves and the side edges. Since the original triangle polyline is created in the direction of the polyline, we have to flip the diagonal line directions first. You can find the side edges in the output of the List Item component. Make sure you check if you are using the correct triangle edges.

  • Flip the direction of the side edges Curve » Util » Flip Curve


Loft the curves of the triangle

By lofting the side edge and Interpolated Curve we can create the shading component surface. Make sure you first simplify the Curve output, to match the data tree of the side edges!

  • Simplify the Curve output RMB on Curve output » Simplify
  • Loft the side edges and Interpolated Curves Surface » Freeform » Loft


Matching data trees by simplifying

As you can see in the following image, by simplifying the Curve output, the data tree matches to the side edges.

Current stage of the model

Now our model looks like this. Unfortunately, both triangle surfaces of the shading component, are in the same direction. In the final step we will fix this.

Step 5 - Getting the negative twin component

The elevation of the current and the target component.

In the final step we will make sure the negative component of the shading system will be inwards, as displayed in this image. To do this, we need to analyze the direction of one of the midpoints, so we can get the opposite direction.

A vector describing the direction of the opening

Find the direction of one of the bottom shading triangle. Connect the Curve Middle to the Point A input of a Vector 2pt and the Point on Curve to the Point B.

  • Connect the bottom Curve Middle to a Point A input of a Vector 2Pt component Vector » Vector » Vector 2Pt
  • Connect the related Point On Curve to the Point B input


Displayed vectors

We now found the direction.

Reverse the vector

Next, we reverse the direction to make sure the direction goes inwards.

  • Reverse the vector Vector » Reverse » Reverse


Move the Curve Middle using the reversed vector

Move the bottom Curve Middle using the reversed vector.

  • Move the bottom Curve Middle using the reversed vector


Replace the D2 input

Replace the D2 input of the bottom Merge component, with the Moved Curve Middle.

  • Replace the D2 input.


The final result

Your shading system now fluently reflects the sun from your attractor point.

Combine the outputs to a geometry parameter

Finally connect the Lofted curves to a Geometry parameter.

  • Finalize your script with a Geometry parameter Params » Geometry » Geometry


The final script

Your final canopy:

Personal tools
Actions
Navigation
Tools