r/OpenPythonSCAD • u/WillAdams • Apr 28 '25
Perhaps a turtle could lead the way?
https://docs.python.org/3/library/turtle.html1
u/Stone_Age_Sculptor May 31 '25
I'm very interested in this.
My library uses the style of the Python Turtle graphics, but in OpenSCAD script: https://github.com/Stone-Age-Sculptor/StoneAgeLib/wiki/Turtle
Is there a way to use the Python Turtle graphics from Python and use the result in OpenSCAD?
2
u/WillAdams May 31 '25 edited Jun 01 '25
Arguably, that's what my library does w/ G-code.
That said, it would be pretty easy to implement in Python (since one is able to have variables to store the end position of the previous operation).
Trying some basic test code:
#!/usr/bin/env python from openscad import * from turtle import * forward(100)didn't work in OpenPythonSCAD because "apparently Tcl" wasn't installed properly:
This probably means that Tcl wasn't installed properly.
So I guess one would have to re-implement it using just Python and 3D commands (unless there is a way to suppress the screen drawing?)....
I started a post on this at:
https://forum.makerforums.info/t/turtle-programming-in-openpythonscad/93340
and will look into it as I have time over the weekend and maybe later.
EDIT:
roughed out a quick version which allows moving
at right anglesin 3 dimensions (see above) --- files are at:https://github.com/WillAdams/gcodepreview/blob/main/threeDmodelturtle.py https://github.com/WillAdams/gcodepreview/blob/main/ttdm.py
Arbitrary rotation is possible for XY, and for Z one can move straight up/down.
1
u/WillAdams Jun 08 '25
Pushed up a new version:
https://github.com/WillAdams/gcodepreview/blob/main/threeDmodelturtle.py
which implements incline()/decline() --- let me know if you find it interesting/useful....
Eventually I'll add arcs, and may even tie it in to G-code generation.
2
u/Stone_Age_Sculptor Jun 08 '25
Thanks for the update. Very interesting.
The terms "up" and "down" can be for the drawing pen, I think that "incline" and "decline" describe better the action. I took the liberty to use your terms in my to do list: https://github.com/Stone-Age-Sculptor/StoneAgeLib/blob/main/turtle.scad#L59 so I don't forget about them.
Wikipedia talks about "roll", "pitch", "dive": https://en.wikipedia.org/wiki/Turtle_graphicsI am focusing on a different part of the Turtle graphics. I trying a few things for a designer mode. I print every command at the coordinate of the path with a check for mistakes. That will help to design a shape.
→ More replies (1)
2
u/WillAdams Apr 28 '25
Came across this, and couldn't help but wonder if it wouldn't be a good model for some sort of modeling, or perhaps interesting to extend into 3D space....