Antony Monjauze had a question about whether OpenSCAD could be used to create a shell from an imported stl. At first I thought this wouldn’t be possible. It seems like to create a shell you would need to know something about the geometry of the stl you were importing, and OpenSCAD can’t tell you anything about what the dimensions of an imported stl are. However Henning Meyer’s comment on this thread explains how it can be done.
The trick is to use the minkowski sum function. The minkowski sum combines two objects by tracing out the volume swept by the second object if it was moved through all the points enclosed by the first object (maybe not a 100% accurate description, but simplest way I can think of writing it down).
Henning’s suggestion was to first of all create a negative of the object you want to shell by subtracting it from a giant cube, then do a minkowski sum of a sphere with the resulting part. Finally you can intersect the result with your original to get a shell. The diagram below shows what this concept looks like in 2D.
Here’s what that looks like in OpenSCAD code…
// Universe cube must be bigger than part being loaded universe_x = 1000; universe_y = 1000; universe_z = 1000; // t is thickness of shell t = 2; // Name of part to convert to shell (must be in same directory) part_to_shell = "DemoPiece.stl"; intersection() { import(part_to_shell); minkowski() { difference () { // Universe cube translate([-universe_x/2, -universe_y/2, -universe_z/2 ]) cube([universe_x, universe_y, universe_z]); // Original part import(part_to_shell); } // Tool for the minkowski shell sphere(r=t, center=true); } }
.. and here’s the result in OpenSCAD (I’ve cut the result in half so you can see the shell).
A great explanation.
Thanks!
For the universe, rather than using a fixed-size cube, using the Minkowski sum of the original shape and a sphere seems to also work. I.e. expand, difference, expand, intersect
Doesn’t seem to work for me. I get an impossible looking object that doesn’t render correctly