3D Designer
Tutorials – OpenSCAD
Ah! What a joy your first 3D printer … but once you have printed your first benchy, where do you go from there? To building your own pieces, of course!
If you do a superficial search online, it would seem that there are two things you can do with your new 3D printer: the first is print benchies (castles and skulls with which to adorn your bookshelf); the second is to create the bits of your next Comic Con cosplay costume you can't make with a sewing machine.
Then there is a subgroup of people who seem to think that 3D printing is an aim in itself, and that the best use of their filament is to build things that further enhance their machines. I am one of them.
Printer Pimping
Truth be said, I have not been this excited over a gadget in years. I was in awe of my first prints and realized this was a thing I wanted to keep in good working order for ever. I found a post on Thingiverse [1] that explained that my printer model had a design flaw: The vent over the electronics was facing upwards; hence dust and little bits of plastic from the prints could fall in and damage the fan. The solution was to print an exhaust vent cover that would propel the flow of air towards the front.
That led to a down-the-rabbit-hole situation in which I ended up printing a drawer that would hold all the printer's bric-a-brac (spare nozzles, screws, bolts, and belts), a tool holder, and an improved filament feeder.
What I could not find was a decent camera holder. You see, continuing with the topic of "3D printer as an aim in itself," a lot of people attach cameras to their printers and then turn the videos into time-lapses, giving birth to that genre of videos on YouTube that show objects seemingly growing from nothing on a printer's hotbed.
There is also a practical reason for training a lens on your prints: Some print managers like Atelier [2] allow you to monitor your prints from afar. If the camera shows the print going wrong, you can abort it before things get really messed up.
None of the available camera holders were any good, either because they didn't fit my cheapo Chinese sports cam, or they didn't fit my printer.
So, I decided to make my own.
CAD Applications
This meant getting up to speed with CAD software for Linux. Blender is great for making artistic stuff for printing, but it is massive overkill just to print cubes, cylinders, and spheres. Because, as I soon discovered, most mechanical pieces are made out of those parts, you don't have to wrap your head around Blender for that.
Besides, you want a simple way of measuring precise lengths, widths, heights, and angles and applying constraints to each and all of them. So far, the best programs I have been able to find for that are OpenSCAD [3] and FreeCAD [4].
In this issue, we'll be looking at OpenSCAD. We'll tackle FreeCAD further down the road in a separate tutorial.
OpenSCAD is interesting because you use a programming language to describe all the objects that make up your pieces. This may sounds scary, but it is not. And, believe me, FreeCAD is much more mind-bending.
Interface
OpenSCAD's relative straightforwardness starts with its interface. The main window is divided into roughly three panes (Figure 1). On the left, you have the script editor, which is where you write your programs. The editor has syntax highlighting and auto-indents lines when you use the JavaScript-like code formatting style (see Listing 1).
Listing 1
Modifying a Cube
// Method 1 translate ([5, 5, 5]) rotate([45, 45, 45]) cube (5); // Method 2 translate ([5, 5, 5]) { rotate([45, 45, 45]) { cube (5); } } // Method 3 translate ([5, 5, 5]) rotate([45, 45, 45]) cube (5);
On the right, at the top, you have the preview pane that shows your objects. Use the left mouse button to rotate the view, the wheel on your mouse zooms in and out, and holding down the right mouse button and dragging pans the view.
Finally, on the right under the preview, you have the console. OpenSCAD shows messages here as it renders your objects. It will also show error messages if it encounters syntax errors or has problems with the objects.
Although everything is important, the File | Examples option in the menu across the top of the window is especially worth exploring. The projects in there will help you get a better grasp of how OpenSCAD works.
Also check out the View menu, since it contains options for updating and changing what you see in the preview, along with keyboard shortcuts to make your workflow more agile. Some of the options available from View are also available in the toolbar under the preview pane.
This covers the essential interface bits. Things get really interesting when it's time to write scripts.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.