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
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.