from extruder_turtle import ExtruderTurtle import math ## Parameters for the spiral N = 40 ## Number of subdivisions of one round-trip radius = 20 ## Outer radius of the spiral dtheta = 2 * math.pi / N ## Change in heading after each step dx = radius * dtheta ## Forward movement during each step dr = -0.5 / N ## Change in radius with each step t = ExtruderTurtle() t.name("alien-tree.gcode") t.setup(x=100, y=100) t.set_density(0.07) # 0.05 t.rate(500) while radius > 0: t.forward(dx) t.right(dtheta) radius += dr dx = radius * dtheta for l in range(50): t.extrude(0.1) t.dwell(100) t.lift(0.05) # 0.1 for x in range(60): for l in range(10): t.extrude(0.1)
FEEDRATE = 700 NUM_HAIRS = 200 LAYER_HEIGHT = 0.3 DIAMETER = 80 NUM_SIDES = 5 LAYERS = 200 dtheta = 2 * math.pi / NUM_HAIRS dx = DIAMETER * math.sin(dtheta / 2) t = ExtruderTurtle() ## Set up the turtle t.name("flex-circle.gcode") t.setup(x=100, y=100) t.rate(FEEDRATE) t.set_density(EXT_DENSITY) for l in range(LAYERS): for k in range(NUM_HAIRS): t.right(dtheta) t.forward(dx) t.left(HAIR_ANGLE) t.forward(HAIRLENGTH) t.dwell(50) t.forward(-2 * HAIRLENGTH) t.dwell(50) t.forward(HAIRLENGTH) t.right(HAIR_ANGLE) ## Move to the next layer
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() t.name("complex-walk.gcode") t.setup(x=100, y=100) t.rate(700) N = 75 period = 224 angle = 2 * math.pi / N for l in range(30): for k in range(period + 1): t.forward(2) t.right(angle * k * (k - 1) / 2) t.lift(0.3) t.finish()
from extruder_turtle import ExtruderTurtle import math N = 60 RADIUS = 12 dtheta = 2 * math.pi / N dx = RADIUS * dtheta dr = -5 / N MAX_HEIGHT = 10 t = ExtruderTurtle() t.name("spiral-tower.gcode") t.setup(x=100, y=100) t.set_density(0.05) t.rate(1000) for l in range(40): radius = RADIUS prop = l / 40 while radius > 0: t.move_lift(dx, prop * MAX_HEIGHT * (-dr) / RADIUS) t.right(dtheta) radius += dr dx = radius * dtheta t.lift(0.2) while radius < RADIUS: radius += -dr dx = radius * dtheta t.left(dtheta) t.move_lift(-dx, prop * MAX_HEIGHT * dr / RADIUS)
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() t.name("stretchy-material.gcode") t.setup(x=100, y=100) t.rate(900) t.set_density(0.05) for l in range(5): for r in range(5): for n in range(4): t.forward(10) t.right(math.pi / 2) t.forward(4) t.left(math.pi / 2) t.forward(2) t.left(math.pi / 2) t.forward(8) t.right(math.pi / 2) t.forward(2) t.right(math.pi / 2) t.forward(4) t.left(math.pi / 2) sgn = (-1)**(r % 2) t.forward(10) t.left(math.pi / 2 * sgn) t.forward(14) t.left(math.pi / 2 * sgn) t.left(math.pi / 2)
"A": "+BF-AFA-FB+", "B": "-AF+BFB+FA-", "F": "F", "+": "+", "-": "-" } GENS = 5 sidelength = 50 / 2**GENS t = ExtruderTurtle() t.name("hilbert.gcode") t.setup(x=100, y=100) t.set_density(0.05) t.rate(800) for g in range(GENS): new_instr = "" for r in instr: new_instr += sub_rules[r] instr = new_instr for l in range(10): for r in instr: if r == "F": t.forward(sidelength) elif r == "+": t.right(math.pi / 2) elif r == "-": t.left(math.pi / 2) t.lift(0.3) for r in reversed(instr): if r == "F": t.backward(sidelength)
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() t.name("horizontal-brush.gcode") t.setup(x=200, y=100) t.rate(700) t.set_density(0.05) for l in range(100): t.forward(5) t.right(math.pi / 2) t.forward(20) t.right(math.pi / 2) t.forward(5) t.right(math.pi / 2) if l % 5 == 3: t.forward(0.5) for i in range(19): t.left(math.pi / 2) t.rate(3000) t.set_density(0.02) t.forward(50) t.lift(0.2 - l * 0.2) t.penup() t.forward(10) t.lift(l * 0.2 - 0.2) t.forward(-10) t.lift(10) t.right(math.pi)
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() ## Set up the turtle t.name("feedrate-test.gcode") t.setup(x=100, y=100) ## Parameters min_rate = 200 max_rate = 10000 height = 200 for l in range(height): ## Feedrate increases linearly from one layer to the next, ## making the extruder move faster and faster t.rate(min_rate + l * (max_rate - min_rate) / height) ## Draw a square for k in range(4): t.move(30) t.right(math.pi / 2) ## Move to the next layer t.lift(0.3) ## Save to a GCODE file t.finish()
from extruder_turtle import ExtruderTurtle import math LENGTH = 20 PILLAR_ROWS = 8 t = ExtruderTurtle() ## Set up the turtle t.name("pillar-array.gcode") t.setup(x=100, y=100) t.lift(0.1) t.rate(700) t.set_density(0.05) num_zigzags = math.floor(LENGTH / 0.4) for i in range(num_zigzags): t.forward(LENGTH) t.right(math.pi / 2) t.forward(0.2) t.right(math.pi / 2) t.forward(LENGTH) t.left(math.pi / 2) t.forward(0.2) t.left(math.pi / 2) t.lift(0.1) pillar_space = LENGTH / PILLAR_ROWS t.penup() t.rate(1500) for i in range(PILLAR_ROWS):
from extruder_turtle import ExtruderTurtle import math import random SIDELENGTH = 20 BUMPLENGTH = 1 BUMP_ANGLE = math.pi / 2 NUM_SIDES = 6 LAYERS = 100 t = ExtruderTurtle() ## Set up the turtle t.name("bumpy-prism.gcode") t.setup(x=100, y=100) t.rate(700) t.set_density(0.07) for l in range(LAYERS): ## Draw a pentagon for k in range(NUM_SIDES): ## Draw one side, with a randomly placed bump x = SIDELENGTH * random.random() t.move(x) t.left(BUMP_ANGLE) t.rate(100) t.move(BUMPLENGTH) t.dwell(50) t.move(-BUMPLENGTH) t.rate(700) t.right(BUMP_ANGLE)