Curve attractor in grid

  • Intro
  • Design
  • Setting up the geometry
  • Curve attractor 2D grid
  • Curve attractor 3D grid
  • Geometry selection
  • Conclusion
  • Useful Links

Information

Primary software used Grasshopper
Course Curve attractor in grid
Primary subject Parametric Modeling
Secondary subject General
Level Intermediate
Last updated May 27, 2025
Keywords

Responsible

Teachers
Faculty

Curve attractor in grid 0/7

Curve attractor in grid

Basics of attractors in Grasshopper

Attractors in parametric design have various applications, ranging from pattern design to more advanced uses like performative design. For example, they can optimize a facade’s performance relative to the sun. This tutorial will cover the basic understanding of the use of attractors in Grasshopper and will explain this by an example of a parametric component system that relates to an attractor. In this tutorial the basics of attractors are explained with a 2D example of a curve used as attractor. The image on the bottom illustrates a curve attractor that determines the radius of a grid of circles. 

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

Curve attractor in grid 1/7

Designlink copied

This tutorial will guide you through creating a grid of points and generating circles at each point. You will learn how to adjust the radius or extrusion of the circles based on their distance from a specified curve.

The variables of the definition will be:

  • Grid of points: 30×30 meters
  • Curve from Rhino
  • Radius of the circles
  • Height of the extrusion

Exercise file

In this tutorial, basics of using a curve as attractor will be explained. You can download the file developed for this tutorial. However, to really understand how the script works, it is recommended to build it yourself.

Curve attractor in grid 2/7

Setting up the geometrylink copied

To prepare for the attractor script we need to prepare a 2D grid and curve. For the first set-up, we are using a 2D hexagonal grid and a curve created in Rhino. Create a hexagonal pattern using the respective component. Define the X and Y size using a numerical input. 

Create a hexagonal grid
Create a hexagonal grid
  • Add a Hexagonal component to the canvas 
  • Vector
    Grid
    Hexagonal

Define the X and Y size with a Number Slider

Params
Input
Number Slider

 

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

Set one curve in the hexagonal grid
Set one curve in the hexagonal grid
  • 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
Curve Parameter
Set one Curve
Curve
Analysis
Curve Closest Point

 

Curve attractor in grid 3/7

Curve attractor 2D gridlink copied

Now that the geometries are created, the curved can be used as attractor in the hexagonal grid. 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 curve and hexagon centers
Find the Distance between curve and hexagon centers
  • Find the distance between the curve and the hexagon centers 
Curve
Analysis
Curve Closest Point

 

Next, we want to remap the available distance values to another range. Make sure you first flatten the distance output! Because the distances vary and have a wide range, we use the remap options to create a smaller range that corresponds to the distance between each point and the curve. In this example, the distances range from 0.018 to 50.2, which are too small or too big for the radii of our circles. Therefore, we remap these numbers in a range between 0.1 and 1.5 to achieve our desired result for our radii. In this tutorial we will not explain the remapping extensively, if you are having trouble understanding the remapping, take a look at the tutorial Curve frames arrays. 

Remap the distances
Remap the distances
  • 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

 

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
Create circles of different sizes according to their proximity to the curve

Curve attractor in grid 4/7

Curve attractor 3D gridlink copied

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. Finally, you will have to cap the cylinders.

: Extrude the circles based on distance
Extrude the circles based on distance
  • 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
  •  

Finally, you will have to cap the cylinders. The result is a cylindrical pattern in which the size of a cylinder is an expression of the distance to the curve.

Cap the cylinders
  • Cap the cylinder holes 
Surface
Util
Cap Holes
  •  

Visualization

You can also visualize your design in different ways. In this step we want to visualize the cylinders according to their proximity to the curve. To be able to do that you can:

  • Use the sort list component to get the highest and lowest limits of our list
  • Sets
    List
    Sort List
  • Use List item to extract the highest and lowest values 
  • Sets
    List
    List Item
  • Connect the highest and lowest numbers to the Upper and lower limits of the gradient component to create a dynamic visualization 
  • Params
    Input
    Gradient
  • Connect the gradient to the material input in custom preview and the brep caps to the geometry input 
  • Display
    Preview
    Custom Preview
Visualize Distance

Curve attractor in grid 5/7

Geometry selectionlink copied

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. 

Extrude the circles based on distance
  • Connect the grid points to the list in a dispatch component
  • Sets
    List
    Dispatch
  • Dispatch the list according to a rule. In this case it is the smallest distance between the points and the curve 
  • Math
    Operators
    Smaller Than
  • Connect List A from the dispatch to the plane input in the circle component 
  • Extrude the circles in the Z-Direction 
  • Surface
    Freeform
    Extrude

Now your final model looks like the following image.

Selecting cylinders based on distance
Selecting cylinders based on distance

Curve attractor in grid 6/7

Conclusionlink copied

This tutorial aims to give a basic overview of how to create a curve attractor on a 2D grid. You will also learn how to visualize your grid in 3D through different approaches using the distance between the curve and the grid points.

Complete Code
Complete Code

Complete exercise file

The final script includes two script option. In both script options you will find the 2D grid points and the curve attractor. In the first script you will find the gradient visualization of the 3D grid according to the curve. In the second script you will find the elimination of the points with greater distances from the curve.   

Curve attractor in grid 7/7

Useful Linkslink copied

Linked Tutorials