Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Python bindings for OpenSCAD

branch: master

This branch is 0 commits ahead and 0 commits behind master

Merged pull request #11 from brad/master.

Ordered transformations
latest commit 886c09b7e6
Ian Daniher itdaniher authored April 27, 2011
Octocat-spinner-32 contrib Emacs major mode by Len Trigg April 07, 2010
Octocat-spinner-32 doc suggestions for constants February 04, 2011
Octocat-spinner-32 examples makes transformations ordered April 27, 2011
Octocat-spinner-32 icons Moved progress display to status bar. Disabled by default but can be … February 10, 2010
Octocat-spinner-32 patches updated to support an installation dir May 09, 2010
Octocat-spinner-32 qxs Merge branch 'qcodeedit' of http://www.gilesbathgate.com/openscad int… April 12, 2010
Octocat-spinner-32 scripts Upload script for binaries January 21, 2011
Octocat-spinner-32 src Made the bool initialiser call the right constructor. April 27, 2011
Octocat-spinner-32 test-code Copyright updates January 21, 2011
Octocat-spinner-32 .gitignore ignore eclipse project files April 25, 2011
Octocat-spinner-32 COPYING Clifford Wolf: February 01, 2010
Octocat-spinner-32 Info.plist Experimental Apple Event hack; you can now do 'tell application "Open… February 02, 2010
Octocat-spinner-32 OpenSCAD.sdef Experimental Apple Event hack; you can now do 'tell application "Open… February 02, 2010
Octocat-spinner-32 README-openSCAD added back in the original openSCAD README February 12, 2011
Octocat-spinner-32 README.mkd fix link in readme February 13, 2011
Octocat-spinner-32 RELEASE_NOTES Update for 2011.01 January 21, 2011
Octocat-spinner-32 bison.pri update qmake file for visual C++ builds January 21, 2011
Octocat-spinner-32 boost.pri update qmake file for visual C++ builds January 21, 2011
Octocat-spinner-32 build.sh nevermind. kevin says that's a bad idea. also, nice weather today. March 08, 2011
Octocat-spinner-32 cgal.pri update qmake file for visual C++ builds January 21, 2011
Octocat-spinner-32 eigen2.pri Extracted eigen2.pri March 31, 2010
Octocat-spinner-32 flex.pri update qmake file for visual C++ builds January 21, 2011
Octocat-spinner-32 glew.pri Use DEPLOYDIR independant of deploy config May 10, 2010
Octocat-spinner-32 mjau.gdb MDI fix and Mac environment for qcodeedit April 03, 2010
Octocat-spinner-32 opencsg.pri Use DEPLOYDIR independant of deploy config May 10, 2010
Octocat-spinner-32 openscad.pro Merge openscad/master February 12, 2011
Octocat-spinner-32 openscad.qrc Moved progress display to status bar. Disabled by default but can be … February 10, 2010
Octocat-spinner-32 openscad_win32.rc Copyright updates January 21, 2011
Octocat-spinner-32 pyscad.py makes transformations ordered April 27, 2011
Octocat-spinner-32 setenv_mjau.sh Use release libs also when developing July 02, 2010
Octocat-spinner-32 valgrind.supp Clifford Wolf: January 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.