Skip to content
Python bindings for OpenSCAD
C++ C Python Shell Emacs Lisp
Pull request Compare This branch is 33 commits ahead, 5322 commits behind openscad:master.
Latest commit 886c09b Apr 27, 2011 @itdaniher itdaniher Merged pull request #11 from brad/master.
Ordered transformations
Failed to load latest commit information.
contrib Emacs major mode by Len Trigg Apr 7, 2010
doc suggestions for constants Feb 4, 2011
examples makes transformations ordered Apr 27, 2011
icons Moved progress display to status bar. Disabled by default but can be … Feb 10, 2010
patches updated to support an installation dir May 9, 2010
qxs Merge branch 'qcodeedit' of http://www.gilesbathgate.com/openscad int… Apr 12, 2010
scripts Upload script for binaries Jan 21, 2011
src Made the bool initialiser call the right constructor. Apr 27, 2011
test-code Copyright updates Jan 21, 2011
.gitignore ignore eclipse project files Apr 25, 2011
COPYING Clifford Wolf: Feb 1, 2010
Info.plist Experimental Apple Event hack; you can now do 'tell application "Open… Feb 2, 2010
OpenSCAD.sdef Experimental Apple Event hack; you can now do 'tell application "Open… Feb 2, 2010
README-openSCAD added back in the original openSCAD README Feb 12, 2011
README.mkd fix link in readme Feb 13, 2011
RELEASE_NOTES Update for 2011.01 Jan 21, 2011
bison.pri update qmake file for visual C++ builds Jan 21, 2011
boost.pri update qmake file for visual C++ builds Jan 21, 2011
build.sh nevermind. kevin says that's a bad idea. also, nice weather today. Mar 8, 2011
cgal.pri update qmake file for visual C++ builds Jan 21, 2011
eigen2.pri Extracted eigen2.pri Mar 31, 2010
flex.pri update qmake file for visual C++ builds Jan 21, 2011
glew.pri Use DEPLOYDIR independant of deploy config May 10, 2010
mjau.gdb MDI fix and Mac environment for qcodeedit Apr 3, 2010
opencsg.pri Use DEPLOYDIR independant of deploy config May 10, 2010
openscad.pro Merge openscad/master Feb 12, 2011
openscad.qrc Moved progress display to status bar. Disabled by default but can be … Feb 10, 2010
openscad_win32.rc Copyright updates Jan 21, 2011
pyscad.py makes transformations ordered Apr 27, 2011
setenv_mjau.sh Use release libs also when developing Jul 2, 2010
valgrind.supp Clifford Wolf: Jan 10, 2010

README.mkd

pySCAD: Parameteric Python Design

About OpenSCAD:

OpenSCAD is an interactive constructive solid modelling tool which provides the ability to design, extrude, and compile 3D objects using a custom C-like syntax.

Built on Qt4, CGAL, OpenCSG, and Eigen, OpenSCAD allows users to describe objects with a functional language, providing a WYSIWYM(what-you-see-is-what-you-mean) interface to solid objects, in a similar paradigm to LaTeX.

This tool provides transformations including scale, rotate, translate, and mirror as well as operations including union, difference, and render intersection. Using just these functions, a wide user base have produced a number of objects including a RepRap variant, from simple starting blocks: cubes, spheres, cylinders, and polyhedra.

It's received lots of good press for its easy of use, versatility, and extensive functionality. However, it uses a custom, slightly archaic syntax, doesn't integrate well with other tools, lacks customization, and requires significant overhead.

We sought to change that.

Why PySCAD?

Python is the language of choice for many developers, especially in the desktop manufacturing sector. Skeinforge, a vital component of the printing process for both Makerbots and RepRaps, is written entirely in Python. It provides multiparadigm programming and a wide range of libraries ranging from computer vision, natural language processing, to web handling. As such, it makes an ideal base for to expand OpenSCAD.

A set of Python bindings to OpenSCAD would provide a familiar syntax, optional object-oriented coding, and greatly increase the ability for automating the design of solid objects.It will hopefully become trivial to add extended functionality to 3d models.

For example, Eagle CAD, one of the most common circuit design tools, is moving to an XML format for boards and parts. It will soon be possible to parse board design files in Python. The next step would be writing a script to automatically design, compile, and print a case for an arbitrary circuit board.

A more futuristic example would be leveraging a text-to-speech engine and a natural language toolkit to allow verbal design of 3d objects.

Technical Details

PySCAD uses ctypes to bind with the existing OpenSCAD code. OpenSCAD internally represents parsed code as an Abstract Syntax Tree (AST). This AST is then evaluated into a tree of nodes that are passed to OpenCSG. PySCAD integrates at the AST level, because it allows us to re-use OpenSCAD's constructors for primitives, as well as wrap other functionality, such as DXF import. A small shim, src/python.cc exposes a C API for instanting OpenSCAD AST objects and forcing OpenSCAD to render them. This is wrapped in a pythonic, object-oriented API.

What's Next?

Lots more development. This project is pre-alpha; we have a solid direction, but lots more to add. Even so, this code provides a useful interface to OpenSCAD. Ian is working on a wrapper library which will provide an object-orented interface to OpenSCAD functions. Kevin is continuing to rock the low-level C++ hacking. We're actively looking for more help. Feel free to drop us a line via Kevin's Blog or Ian's Site.

Something went wrong with that request. Please try again.