How to apply a function to each distinct closed crv individually


I want to rotate each square randomly. So each one is at a different angle. And want to apply this to a lot more crvs in the future. I’m confused about this. The graft function isnt working

Assigned to Grasshopper category

10 squares rotated randomly (0° to 90°).

random (8.2 KB)


Hi Kevin, thanks for the reply-- this script, I think, dodges my question in that I’m asking how to rotate x number of shapes each randomly, rather than creating an array of randomly rotated self-similar shapes.

For reference if this makes it more clear, I have 14,000 existing shapes I need to rotate randomly. Each distinctly and from their own center.

The technique would be exactly the same. What difference does it make if you already have the shapes or they are created in grasshopper?

Post a file with your shapes and I will show you.


Tfile.3dm (77.6 KB)
Does this work? I put two sets of shapes I want to rotate randomly. each distinctly.

Each type of geometry requires a different strategy to find its center point so I separated the closed and open curves, found their center points, then re-combined them.

The asterisk like shapes are individual lines, so they rotate individually (what you asked for). If you want them to rotate as a group, you will need to group them.

Rotated shapes were moved upward so both sets of shapes could be viewed at the same time.

rotate (14.2 KB)


Here’s another example.

rotate (17.2 KB)

The letters are curves that are grouped in branches of a DataTree. This means the inputs to the Rotate 3D component have the same branch structure (each has 26 branches).

Again the rotated objects were moved upward so original and rotated could both be viewed at the same time.



Putting a union box in your file made individual boxes on each letter, when I do this it does a box around all of the objects, they are separate groups. here’s my file
rotate (26.2 KB)

Unless I’ve misunderstood, I think you almost had it?

Check this: (13.7 KB)

Yes, this is because the curves that make up the letters are arranged in a DataTree with one branch for each letter. Note the wires are shown as dashed lines, this means that they are carrying a DataDree. I’ve used the Bounding Box component to find the center of each group to use as the center of rotation for the group.

Your objects are all in a single list (note the wires are shown as thick solid lines). So the Bounding Box component groups them into a single box and uses it’s center as the center of rotation for each item in the list.

Here’s another example using your “asterisk” shapes.

The start points of the lines that make up each “asterisk” shape are at the center of the shape. I’ve taken advantage of this and used the Group Points component to group them into the branches of a DataTree.

rotate (13.8 KB)

The management of lists and DataTrees is something that many people new to grasshopper struggle with. Learning to sort and group your data into lists and trees and managing the flow of that data through the components in your definition is essential to being effective with grasshopper.