A Python package that uses the principles of 3D Turtle Geometry to generate GCODE. To be used as a Grasshopper/Rhino library. Relies on Rhinoscript functionality. This file covers only a subset of library funcitons. For full library documentation see: https://handandmachine.org/projects/extruder_turtle_rhino/ Rhinoscript documentation: https://developer.rhino3d.com/api/RhinoScriptSyntax/
The ExtruderTurtle
class implements the basic functionality of a turtle.
Methods of the ExtruderTurtle
class that are used to set up your turtle:
- The constructor
t = ExtruderTurtle()
which takes no arguments. The turtle is constructed with no associated GCODE file or 3D printer and these starting parameters:- Default starting orientation, consisting of three vectors:
forward_vec
(which you may imagine as pointing out of the turtle's nose),up_vec
(normal to the turtle's shell), andleft_vec
(pointing out of the turtle's left side). - Default starting
pendown
value isTrue
. - Angles are measured in degrees.
- Default starting orientation, consisting of three vectors:
- To associte the turtle with a GCODE file and 3D printer, use
t.setup()
, with arguments:x=0
is the starting x-valuey=0
is the starting y-valuez=0
is the starting z-valuefilename=False
the value of the file you need to write to. You must open a file with write access in Grasshopper/Rhino and then pass the name of this file to the setup function.printer=False
the printer you are using. The library currently supports the following printers: Ender Creality 3D "ender", 3D Potter Super 10 "super", 3D Potter Micro 10 "micro", and Eazao Zero "eazao".
- To close the GCODE file and write the finalization sequence to the output file, use
t.finish()
. This cools down the bed, moves the extruder up and away from the print, etc.
Some available actions for the turtle:
t.forward(distance)
moves the turtle forward a distance ofdistance
, extruding along the way and writing GCODE if the pen is down.t.lift(height)
lifts the turtle up by a distanceheight
. Usually used to move to the next layer of the print.t.left(theta)
turns the turtle left by an angletheta
. This is just an easier-to-remember alias fort.yaw(theta)
.t.right(theta)
turns the turtle right by an angletheta
. Alias fort.yaw(-theta)
.t.penup()
lifts the pen up (extrusion will not occur until the pen is back down).t.pendown()
puts the pen down (extrusion will occur until the pen is lifted up again).
The following functions are used to configure the turtle and write directly to the GCODE file:
t.set_extrude_rate(extrude_rate)
sets the rate of extrusion, that is, the ratio of mm filament extruded to mm moved by the turtle.t.set_speed(speed)
sets the speed (AKA feedrate) of the turtle.t.extrude(quantity)
extrudes the given quantity (in mm) of filamentt.write_gcode_comment(comment)
writes the input string to the GCODE file as a comment
The following functions are used to generate geometry objects that you can manipulate and visualize in Grasshopper/Rhino:
t.get_lines()
returns the path traveled by the turtle as a list of lines.t.draw_turtle()
returns a triangular surface that shows the turtle's current location and orientation.t.draw_print_bed()
returns a surface that corresponds to the size of the printer's print bed.
See the examples directory.