Friday, May 29, 2015

Turtle Blocks and 3D Printing


Walter Bender has graciously added a couple of new blocks to Turtle Blocks JS, an online version of Turtle Blocks programming, to aid in creating designs for 3D printing.

We can recreate the TurtleArt Dragon Curves procedure in Turtle Blocks. Walter also added a One of block to Turtle Blocks to make this possible. Start by creating a zig procedure.


When you create your master procedure you need to add a couple of blocks to make the SVG ready to import into Tinkercad.


First, suppress the background by adding the red "no background" block. Next, add the begin hollow line block before the turtle starts drawing. Once the design is drawn, add the end hollow line block to the procedure.

The design will look a little unusual when you run it. An SVG file downloads at the end.


The scale at which you import your design into Tinkercad depends on the size of the build plate on your 3D printer. I sized scaled my import to 25% and further reduced the size of the model once it was imported.



The resulting model sliced fine in ReplicatorG. I printed the model with 2 shells and 5% infill on my Thing-O-Matic.


Turtle Blocks takes a few of the hurdles out of trying to get a turtle graphics project 3D printed. By streamlining the process and eliminating the intimidating step of getting Inkscape running and converting PNG files to SVG files, Turtle Blocks should help more people experiment with programming 3D printed designs.

Wednesday, May 27, 2015

Exploring Dragon Curves in TurtleArt

Vi Hart's video about dragon curves helped me understand the math behind this wonderful fractal.



Once I understood the dragon curve to be a series of 90° turns that occur in an either/or logic, I adapted the math to a TurtleArt simulation.

In order to make as large a dragon curve as we can potentially fit in the TurtleArt screen, we will keep the turtle's forward movement small. Let's start with forward 5. It is such a small movement that the turtle's mark will be obscured by its body.


As Ms. Hart explains in her video, the turtle should then make the decision to turn left or right. There are turtle movement blocks to make the turtle turn.


However, stacking those blocks would make the turtle turn right, then left, effectively canceling the turn.

Instead, we will use the set heading (seth) block. This allows us to set the turtle's heading in a specific direction by specifying the degree to which the turtle faces. 


We still need to build in a basic logic in the turtle to decide whether to turn left or right relative to the position it is currently facing. We will use the one of block in conjunction with the set heading block to achieve our goal.


When this block runs, sometimes the turtle faces -90 degrees from its current position, while other times it faces 90 degrees from its current position. In the examples below I reset the turtle to 0° before running the procedure.



Finally, program the turtle to move forward 5, and name the procedure. I used Ms. Hart's naming convention.


The red mark is a little heavy. We can make the turtle's pen smaller.


A master procedure to erase the screen, set the pen size and color, and call the zigzag procedure produces a program to generate dragon curves.


Each time the procedures runs a different dragon curve is produced.



Once you have a working zigzag procedure that you can use to produce dragon curves, remix it. Make the turtle go a little farther forward to create a larger dragon curve.


Combine the original zigzag procedure with your new bigzig procedure in a new master procedure that draws both a small dragon curve and a large dragon curve.


Running a large and small dragon curve together produces interesting variations.


Using the method described in the 3D Printed TurtleArt Tiles chapter of my book, you can also produce 3D prints of dragon curves.


Dragon curves are a fractal that, as it turns out, is a fun programming challenge for TurtleArt. The beauty lies in the fact that the procedure creates a different dragon curve each time it runs, art as elusive as the dragons of myth. Save a copy of the designs you like before running the procedure again. 


Once the master procedure clears the screen, you will never see that dragon curve again!

Monday, May 25, 2015

Programming Organic Shapes in Beetle Blocks for 3D Printing



Eric Rosenbaum's Beetle Blocks is a programming environment built on SNAP. It uses a familiar block programming metaphor to produce STL files for 3D printing in an unconventional manner for those of us used to using CAD programs to design 3D models.

The included examples include a few different shell shapes that demonstrate how to make the beetle extrude and move in interesting patterns. I decided to head to the beach with my son to collect some shells. I would try to program their general shapes and see what kinds of models I could create for 3D printing.


While my son collected quartz I went looking for shells from the common slipper shell, a sea snail. There is a beach further down the coast where there are hip-tall piles of these shells.


When they are alive, the sea snails cluster in clumps around a stone or a buoyant object: I once found many clinging to an old golf ball!




I brought home a sample of the shells. I started by examining one of the Beetle Blocks projects that generates a shell. I figured out what the combination of blocks did, then remixed the project to approximate the shape of the slipper shell. One simply exports an STL directly from Beetle Blocks.


I tried and failed to get MeshMixer on Ubuntu 14.04 to slice a plane from the bottom of the model to flatten the base: Meshmixer will not save. I used Tinkercad instead.


I sliced the model in ReplicatorG and specified 0% infill. Still, the model had some strange complexities to it because I was rotating on the x and y planes (I lost that work and had to recreate it for the screenshot above but could not remember how I did the x rotation in the model I originally generated).


I printed the model on my Thing-O-Matic. Originally I scaled the model too small and the filament retraction eventually worked the filament loose in the extruder.

Scaling the model up resulted in a strange, complex, but very organic looking 3D print.














As I continue to program in Beetle Blocks I am beginning to understand how to control the extrusion and movement on the x y z axis creates interesting designs

My second design sought to mimic a snail shell. 



This model required support in order to print. 




Additionally, the model, as programmed, is pretty "messy." The printer is well-tuned, but the model appears to be stringy. Inside, the toolhead path is insanely overly complex, probably because of the beetle's path to create the model and the way the path is rendered into an STL. However, the roughness of the model, in my mind, contributes to the shell's design as it makes it look weathered like it washed up on a beach.



The model took a little over five hours to print.



After removing the support the model beautifully mimicked an invented shell shape. I was even able to remove the support material from inside the model.






You can see the complexity of the toolhead path in the exterior of the print.




I look forward to the opportunity to talk with Eric about Beetle Blocks and to better understand this unique programming environment.