~boringcactus/turtle3D-grasshopper

turtle3D-grasshopper/README.md -rw-r--r-- 1.9 KiB
c7eda59f — Melody Horn move primary links to github 1 year, 7 months ago

#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.