3D Object Scripting using OpenSCAD and Perl
Control. That’s what we all desire and very rarely acquire. The natural restlessness that occurs when you watch one of your offspring flicking from one movie title to the next, barely glancing at the summary before rejecting it, is one of the reasons I don’t like family movie night. My daughter’s grip on the remote is as strong as her decision making skills are weak; I struggle silently to hold back any outburst that would expose my failing parenting abilities once again. I have to distract myself with thoughts of the good old days when the TV had only 4 channels and Teletext was the closest thing to internet. Desiring such regression is now getting much of a habit for me. But we change what we can, accept what we can’t and trust, often foolishly, that those blessed with control do the best for all of us. Ah, look. Another teen fantasy horror romance movie. Thanks a heap, Netflix.
It is no surprise that we seek this control in many things, in work, in politics, in family life, in code. Other people satisfy this need, making powerful tools that does everything one might want; thank you guys, you are legends. But even so, this appears not enough. I occasionally try 3D design and use cleverly engineered CAD tools to make useful shapes with my clumsy gestures on a mouse and clicks on a keyboard. Occasionally I try my hand at coding in Perl. Perhaps I could blend the two. Both Perl and OpenSCAD are scripted tools which themselves can produce textual yields. Python is already used to enhance OpenSCAD, and there is perhaps no reason for Perl to match or even exceed this capability. It should be possible to generate .scad
files and even post-process the STL files that follow.
CAD::OpenSCAD
is a module I started recently. A simple tool that can generate .scad files in a Perlish way. I also used this to learn Object::Pad but in way that will be open to criticism I am sure. I avoid signatures to allow for polymorphism. I avoid multiple classes for for now simplicity until it is more clear what a final class structure should be. Experimenting with this has been interesting. What has been fascinating is is how easy it is to generate scripts that can let another program do all the heavy lifting. But this is a project in its infancy; I have barely scratched the surface of OpenSCAD can do.
OpenCASCADE is another interesting project being explored, this time by Michael Conrad, introduced to me in a Reddit post. His work has just demonstrated to me how little I know. OpenCASCADE has many features not available to OpenSCAD. Indeed, there are many CAD tools that are more capable; I am hoping that its scriptabilty, and a hybridisation with Perl would allow more sophisticated features for programmatic object generation and data visualisation.
Leave a comment