Using Snap! to generate OpenSCAD scripts


I use TinkerCAD as my main 3D tool and decided to try out it’s Codeblocks option to parametrically construct a 3D object (namely a gridFinity bin)

I managed to do it but then got an error message about exceeding 200 primitives and realised that I’d hit its limits

So, I decided to look into using OpenSCAD instead but then had an idea!

Snap! has an example project called Codification which shows how Snap! blocks can be transcoded into JavaScript, Smalltalk, Python and C

So, I thought – I wonder if I could adapt this into generating OpenSCAD scripts.

And the project went very well. Not only was it relatively easy to modify the Codification example to cope with simple OpenSCAD syntax, it turned out that OpenSCAD has a great feature to monitor changes in .scad files.

So every time I exported an updated .scad file from Snap!, OpenSCAD would updates its preview automatically 🙂 This meant the workflow was nearly as good as using Codeblocks in TinkerCAD – but with all the power and customisation offered by Snap!

I started a thread on the Snap! forum but I’ve realised that I’m going to have to document the project a bit more than that. So this is the place that I’m going to do that

Getting Started

Install OpenSCAD on computer (can be Windows/Linux/MAC)

Open it up

Open a web browser and open

Make sure the rocket sprite is selected (You should see this script)

Then, from the cogwheel settings menu, enable JavaScript extensions (just used to make it easy to export the .scad generated file)

Enable JavaScript (just used to make it easy to export the .scad generated file)

Then press the spacebar and an OpenSCAD script should be generated and your browser will download it (or offer to download it depending on browser settings)

Once the Snap_rocket.scad file has been downloaded, switch to OpenSCAD and open it up – you should see the rocket 🙂