~boringcactus/turtle3D-grasshopper

A Python library implementing 3D graphics in a way that can be used within Grasshopper
c7eda59f — Melody Horn 3 years ago
move primary links to github
78912df1 — Melody Horn 3 years ago
add screenshots to tutorial
4c44df65 — Melody Horn 3 years ago
how did that get there

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~boringcactus/turtle3D-grasshopper
read/write
git@git.sr.ht:~boringcactus/turtle3D-grasshopper

You can also use your local clone with git send-email.

#turtle3D for Grasshopper

A Python library implementing 3D graphics in a way that can be used within Grasshopper.

#Installing

Download the turtle3D.py script and place it somewhere on your computer, in a folder by itself. Then open Rhino, go to Tools > PythonScript > Edit..., go to Tools > Options, and in the Files tab, under Module Search Paths, click the "Add to search path" button, and then find the folder you put turtle3D.py in.

#Using

Add the following script to a Grasshopper Python node:

from turtle3D import *

home()
pendown()
forward(10)
right(45)
forward(12)
right(90 + 45)
tiltdown(30)
forward(20)
a = lines()

This will create a turtle automatically, provide it the given instructions, and output the lines it has drawn to the a output of the Python node.

Important: If you omit the call to home() at the start of the code, you will get a NullReferenceException when the Python node runs for a second time. I do not know why this happens, but I believe it has something to do with the fact that the implicitly-created turtle is persisted between runs of the Python node.

#Multiple Turtles

If you wish to create turtles explicitly, or you wish to keep imported names to a minimum to avoid name collisions, this code will have the same effect as the above code:

from turtle3D import Turtle

turtle = Turtle()
turtle.pendown()
turtle.forward(10)
turtle.right(45)
turtle.forward(12)
turtle.right(90 + 45)
turtle.tiltdown(30)
turtle.forward(20)
a = turtle.lines()

#Full Tutorial

I've also written a full tutorial for this library.

#License

This library is released under the terms of the Anti-Capitalist Software License v1.4.