Pattern Generation in Grasshopper
by s_paul in Workshop > 3D Printing
243 Views, 1 Favorites, 0 Comments
Pattern Generation in Grasshopper
![IMG_4591 2.JPG](/proxy/?url=https://content.instructables.com/FOU/YJHI/LIOKZ832/FOUYJHILIOKZ832.jpg&filename=IMG_4591 2.JPG)
The goal of this project is to create a grasshopper workflow for making a 3D-printable lattice design with holes at certain locations. This is for 3D printing on pre-stretched fabric to create wrinkles. I struggled to do this by calculating intersections with a generated grid, so I decided instead to draw 1 unit cell of my pattern, draw a cutting shape (circle), then use the array function to tile it. Then, I 3D printed one pattern.
Here is the grasshopper file I used in this example.
Supplies
Grasshopper/Rhino
Motivation
![66967555831__FFF04E66-6B2E-428A-9993-0137A6528BF2.jpeg](/proxy/?url=https://content.instructables.com/FQJ/IKRV/LIOL06UB/FQJIKRVLIOL06UB.jpg&filename=66967555831__FFF04E66-6B2E-428A-9993-0137A6528BF2.jpeg)
![4FB16DE1-3420-4644-A625-8E68F08D0FC1.jpeg](/proxy/?url=https://content.instructables.com/FTK/RAAH/LIOL06UC/FTKRAAHLIOL06UC.jpg&filename=4FB16DE1-3420-4644-A625-8E68F08D0FC1.jpeg)
The motivation for this work is some previous work of mine. I 3D printed some cellular patterns onto pre-stretched jersey, which created these 3D forms when removed from the print-bed. The main drawback here is that I made these manually in Fusion360, which isn't always ideal and takes more processing time. I wanted to automate this process and make it more easy to modify quickly by writing a script in grasshopper. This is still in progress, and I've only done this with one pattern.
Draw Unit Cell
![Screenshot 2023-06-12 at 10.00.39 PM.png](/proxy/?url=https://content.instructables.com/FWT/M4JJ/LIOKZ7BR/FWTM4JJLIOKZ7BR.png&filename=Screenshot 2023-06-12 at 10.00.39 PM.png)
![Screenshot 2023-06-12 at 10.02.44 PM.png](/proxy/?url=https://content.instructables.com/FKO/D2HC/LIOKZ7BW/FKOD2HCLIOKZ7BW.png&filename=Screenshot 2023-06-12 at 10.02.44 PM.png)
This step can be done outside of grasshopper, but my first pattern is a zigzag, so I programmed it in grasshopper so I could easily change the aspect ratio of my zigzag.
I will attach the entire script at the end, but here is the part of my code that generates one unit.
Cutting Holes
![Screenshot 2023-06-12 at 10.05.19 PM.png](/proxy/?url=https://content.instructables.com/FJI/N8GW/LIOKZ7GM/FJIN8GWLIOKZ7GM.png&filename=Screenshot 2023-06-12 at 10.05.19 PM.png)
![Screenshot 2023-06-12 at 10.05.15 PM.png](/proxy/?url=https://content.instructables.com/F9M/9IUJ/LIOKZ7GN/F9M9IUJLIOKZ7GN.png&filename=Screenshot 2023-06-12 at 10.05.15 PM.png)
I used Rdif (region difference for this step). First, I generated the start and end points of each line segment using Endpoints (End) and used those points as the center of each circle. I selected the radius to be slightly larger than the offset distance so the shapes don't touch in the array.
Tiling for an Array and Extruding to Make a Solid Object
![Screenshot 2023-06-12 at 10.06.34 PM.png](/proxy/?url=https://content.instructables.com/F65/6OSP/LIOKZ7IX/F656OSPLIOKZ7IX.png&filename=Screenshot 2023-06-12 at 10.06.34 PM.png)
![Screenshot 2023-06-12 at 10.07.18 PM.png](/proxy/?url=https://content.instructables.com/F2X/WCXS/LIOKZ7JC/F2XWCXSLIOKZ7JC.png&filename=Screenshot 2023-06-12 at 10.07.18 PM.png)
I used a rectangular array to start, and made a 10x10. Then, I capped it to make the object solid, and converted to a mesh. Then I Baked and exported the file into my slicer for a Print. Due to time constraints, I only Printed a 2x2 array, but pattern generation was the focus. You can also define an array along a curve, or a polar array.
Troubleshooting Notes
In the future, I would really like to make these holes using an intersection method. I'll post an update if I can get that working. I was able to calculate intersection points, but I wasn't able to trim the correct parts of the curve.
Here are some of the tutorials I tried (but did not get to work for my geometry):
- https://pedroazambujavarela.net/multiple-split-curves-or-shatter-all/
- https://www.youtube.com/watch?v=ICLLRissfLw&ab_channel=ParametricPhilosophy
- https://parametricbydesign.com/grasshopper/how-tos/split-curves/
Here are some of my in-progress scripts in GH.
Future Directions
I really want to translate some of my old patterns into this workflow, and use the intersection method to trim the holes. I tried doing this by calculating intersection points and using closed regions, but neither of these worked, even on only 1 unit. I know the best way is python, so I need to learn some python to continue this.