~cedric

it's something ¯\_(ツ)_/¯

Woodworking, vim, and OpenSCAD

April 17, 2020 — Cédric Dekimpe

When I’m not coding, I like to spend time building stuff with my hands – I mean real, physical stuffs. I’m certainly not a fine woodworker but I enjoy spending time in my garage and put a few pieces of wood together and make something out of it.

So far I’ve build two play tables for my kids, a mallet, a stool, and a roman workbench, and all of that with little to no plan. I’ve been lucky and never really got into trouble by lack of planning, but with the next projects I have in mind, I feel like  I need to design a little bit beforehand just to be sure I’m not doing anything stupid.

A stool I've built

The problem? I’m really bad at designing, and it’s even worst when 3D is involved. One of the woodworker I follow on YouTube, Steve Ramsey, often says he uses Sketchup to plan his projects before going into his shop, so of course I tried it and failed it. I’m just not the graphical type, and I hate using a mouse on top of that – I don’t even own one anymore.

Until a few days ago, where I stumble upon OpenSCAD, which seem to have been created for people just like me : OpenSCAD, as the name implies, is a CAD (Computer-aided design) program, but instead of using your mouse to move 3D objects on an plan, you use your keyboard and code your way out of it.

Of course I knew this was for me, so after installing it on my computer i ran openscad and read the doc but only a few minutes in, i felt the frustration growing inside me : vim has spoiled me, and writing in anything other than vim feels like a physical pain.

Fortunatelly, vim truely is awesome, and i managed to do exactly what i wanted to mimic from the OpenSCAD IDE : exporting a graphical version of my model as soon as i save the scad file and opening it in feh as soon as I open a .scad file.

Screenshot of a scad render alongside its code in VIM

Here’s how I did it :

" Compile openscad image on save autocmd BufWritePost *.scad :silent !openscad -o %:r.png % " Automatically open png version of a scad file with feh on opening autocmd BufRead *.scad :silent !feh %:r.png&

If you’re looking for a syntax highlightling plugin, you might find this one usefull : sirtaj/vim-openscad

Now I’m planning on building a shelf – once again for the little ones – and this is what i came up with so far. It’s not much, but it made me realize that what I had in mind wasn’t exactly realistic or aesthetic.

Final result of the shelf unit I designed in SCAD

For those interrested, the code is available on my GitHub.