[patch] External scripts

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[patch] External scripts

Owen Taylor
Here's the functionality I promised  a few days ago - to repeat the
basic idea, is that if your OpenSCAD file has:

 script(file="icosahedron.py", r=r);

it calls the script passing in the command line arguments (plus $fn,
$fs, $fn), parses the output as an openscad script and inserts it into
scene graph at that point. I've also attached the Python helper module
I've been using and a few simple examples. The Python module is just
convenience - there is nothing at all about that this that limits the
scripts to Python.

It's been a while since I've done C++, and I don't have a firm grasp
of the OpenSCAD code yet, so feel free to throw the patch back for
style reasons, or any other, and I'll fix it up. (In particular,
subprocess.cc is just a bunch of good-old-Unix-code with a thin C++
veneer, since I had some problems getting QProcess working and doing
what I needed.)

As I described in my other mail, I'm not really sure that the
interface is right - it might make more sense to have:

 external_module icosahedron(file="icosahedron.py")

define a module, since that seems to frequently be what you want.

- Owen

openscad-external-script.patch (19K) Download Attachment
openscad.py (6K) Download Attachment
icosahedron.py (4K) Download Attachment
icosahedron.scad (186 bytes) Download Attachment
screw.py (5K) Download Attachment
screw.scad (170 bytes) Download Attachment