loading

This Instructable will teach you how to create generative objects with Processing code that can be 3d printed. One of the delights of using generative code to print things is that you can randomize certain elements so that every time you render a piece, it's completely unique. I was heavily inspired by the jewelry of Nervous System, which demonstrates this concept beautifully.

If you've never used Processing before, it may be helpful to look at a beginner tutorial first.

You will be using:

*There is a newer version now, Mk2 (however, the code in this tutorial was written before it came out and only works with the original Modelbuilder)

BTW, I'm using a Mac, but you should be able to do it with Windows and Linux too.

Step 1: Setting up the environment & sketch

To get started, you should download both the applications needed, Processing and Netfabb.

You should also grab Modelbuilder's source code from Github. In the modelbuilder master folder, navigate to export > Modelbuilder v0007a03. The folder inside there, called modelbuilder, is what you should move into your Processing libraries folder.

Once you've got everything in the right place, open Processing and create a new sketch.

The code here shows the basics of what you need to initiate your model object and bring up a blank canvas. If it throws and error on the first line, make sure your ModelBuilder library is in the right place, and that within it, the 'unlekker' folder exists inside of 'src'.

Step 2: Create a 3d shape

What kind of shape you decide to make is up to you. You can start with something simple just to wrap your head around making 3D shapes with code, or you can use my code. I decided to make a cluster of hollow pyramids that are set to random heights each time to sketch is run.

Step 3: More ideas: get creative with your interface

If you want to go a step further, you can make your sketch interactive by creating an interface that accepts input. For example, you could add sliders to your sketch's interface to adjust the heights of the pyramids, or make the grid size customizable.

The example shown is the interface for another project, where I made my own custom bracelet generating app. I made a program that allows users to design their own pixelated icon on a 16x16 square grid. The program then takes the design and repeats it all around the bracelet, with holes containing Xs filling in the black pixels.

Step 4: Export & resize in Netfabb

Once you've decided on a shape to make and have previewed it by rendering your sketch, you'll see in the code there's a line to export the model to an STL file (a common 3d format) when you hit the 's' key. That's one of the cool features of ModelBuilder.

Go ahead and test the export function and make yourself an STL file, which you should find in the same folder as your sketch. Then open that file up in Netfabb (Project > Open.).

In Netfabb, you'll first want to adjust the size of your object. Because pixels don't really convert into physical world units, you may find that the shape you exported is way bigger than expected. Make sure your shape is green, indicating that it's selected. The Netfabb interface will show you your object's dimensions in the bottom right, and you can use the Scale Parts tool in the top icon menu bar to resize it. I made the base of the pyramids shape 100x100mm.

Step 5: Repair the object

You may have noticed a big red exclamation point in the bottom right of the window. This means your object has been diagnosed with a hole that shouldn't be there, or maybe the edges don't quite fit, or something else is wrong, so you need to click the red first aid icon at the top to start fixing it. You'll then see a panel in the bottom right called Status. Play around in the Actions panel (right next to Status), until you have 1 shell (i.e., a single object), and 0 for border edge, invalid orientation, and holes. I managed to repair my object by clicking Close all holes, Stitch triangles, Fix flipped triangles, and Remove double triangles. For more info about repairing, check out the Netfabb wiki and this tutorial by Shapeways.

After you've done that, right/ctrl-click Part Repair on the right side bar, and select Apply Part Repair. In the dialog box that pops up, select "Remove Old Part".

"Your Part (Repaired)" should be selected in the right bar, and there should be no exclamation point indicating your part is error-free, so it's time to export this new and improved version of your object. Select Part > Export Part > As STL. If you get a dialog box that says "Some file formats do not include information. This may result in errors" you should click Optimize, and everything will be good to go.

Step 6: Print your object

Now you're ready to send your object to a printer. I used Shapeways, but maybe you have access to a 3d printer somewhere else.

If you are going to use Shapeways, make an account on their site, and follow the instructions on the Design tab at the top of the page to upload your design. You'll see that they tell you how much material your design uses and how much it'll cost, which may make you want to tweak your design to see if you can shave it down a bit.

Here's what I got back, printed in "frosted detail" translucent plastic. My next step is to make a PCB with addressable LEDs to put inside it so I can light up each pyramid and make some sort of tabletop light art object.

Happy printing!

<p>Hello,</p><p>As I am familiar with Processing I like your approach.</p><p>One question: would it be possible to generate just the surface, not care for the thickness, and have another tool care for the thickness?</p>
<p>I'm having trouble getting processing (v. 3.0) to import the Modelbuilder Library... Any suggestions?</p>
<p>New version here: <a href="https://github.com/katherinel/generative_pyramids_p3_0" rel="nofollow">https://github.com/katherinel/generative_pyramids_...</a></p><p>Grab the latest zip from the the export folder of the modelbuildermk2 repo. Put that in your Processing libraries folder.</p>
<p>Hi,</p><p>Is there something specific i should know about model.writeSTL? because, i copied your code, to see how it works, but i had some errors on writing STL files. </p>
<p>Would need to know what the errors are that you're getting...</p>
<p>The method writeSTL(String,ArrayList&lt;UGeo&gt;) in the type UGeo is not applicable for the arguments (generative_pyramids_p3_0, String)</p>
<p>Found a fix while poking around the library examples. In the modelbuilderMk2 version 0162, change on line 100: </p><p> model.writeSTL(this, &quot;Pyramids.stl&quot;);</p><p>to:</p><p> model.writeSTL(sketchPath(&quot;Pyramids.stl&quot;));</p>
<p>Unfortunately it's hard to debug this kind of stuff without seeing all of your code. A better place to get help would be posting to the Processing forums or Stackoverflow, or you can PM me directly.</p>
<p>Thank you for your explaination. It was very usefull to start with Modelbuilder!</p>
<p>Thank you, glad to hear!</p>
<p>Very good.</p>
<p>thanks!</p>
<p>I love what you printed, the shapes are so interesting, also I really like the ones with the bows. It's awesome that you shared how you managed it, very useful to 3d printer people. Thanks for sharing!</p>
Thank you very much! :)

About This Instructable

15,446views

126favorites

License:

More by katherinel:Pixelated Flower Lights Generative 3d Printing with Processing 
Add instructable to: