I found some STL files for a 3D printer, which are mainly linear extrusions of a 2D shape:
I would rather cut on a laser cutter. How can I convert them to a 2D SVG file?
I found some STL files for a 3D printer, which are mainly linear extrusions of a 2D shape:
I would rather cut on a laser cutter. How can I convert them to a 2D SVG file?
One solution is the free and open source OpenScad, the programmers' solid 3D CAD modeller. This solution was inspired from the article on batch processing in OpenScad. The following four lines of code import the STL file and project the 3D shape along the Z axis. The OpenScad script is:
param1=0; // param1 is the keyword of the first shell argument
FileToLoad=param1;
echo(FileToLoad);
projection() import(FileToLoad);
To automate this, a bash script processes all STL files in the Downloads folder, including subdirectories, passes the STL file to the above OpenScad script, and saves the result as SVG. Assuming that the above code is in ~/Downloads/slicer.scad
, the bash script is:
for entry in $(find ~/Downloads -type f -name *.stl)
do
new_entry=$(echo $entry | sed 's/.stl/.svg/g')
openscad -o $new_entry -D param1=\"$entry\" ~/Downloads/slicer.scad
echo "$new_entry"
done
The resulting SVG is below:
If one opens the STL file in a cad program and watches the model in XY plane, he can see something which is at first quite promising:
I thought at first that saving the projection as PDF or SVG (both are possible), opening it in Illustrator or Inkscape and deleting unwanted lines does the trick.
BUT...
The STL is actually a 3D surface made of thousands of small triangles. Here's a piece seen from tilted direction:
There's no curves. The XY plane projection contains thousands partially overlapping straight line segments. They freezed Inkscape and made Illustrator slow. Any attempt to make a single shape with the Shape builder freezed Illustrator. In Illustrator it was possible to select lines and delete them. The PDF version worked a little faster than the SVG version. In Inkscape I did not get anything useful from either.
The downloaded shapes are quite simple so I recommend you to redraw them. If you get the XY plane projection to Illustrator as I did, you can lock it and draw with the pen tool your own version. As well you can use a screenshot as your model. You can get the screenshot for example from SketchUP.
Screenshot is so light computer load that you can draw on it in Inkscape.
Drawing it is also the way to get non-overlapping contiguous paths. I bet the laser cutter wants them.
ADD: just to test the drawing process over the PDF I drew one shape in Illustrator with the pen. It took maybe six minutes. The curves are not perfect, but they are drawn fast. Actually only the left half of the shape was drawn because the shape is symmetric. The right side is a flipped copy.
If you are interested in fighting a little more with a CAD program, you can try to simplify those extrusion shapes there. It's not especially difficult if you use a simple enough program. Do like I did, get a free demo of TurboCAD Deluxe and open the STL file. Select all and goto Format > Explode:
It removes all surfaces and leaves a bunch of polylines which float in the space. A tilted watching direction shows that a big part of the sides of the surface triangles have vanished there's left only the basic skeleton:
Then turn the projection straight sideways and select all but those lines which are in XY plane:
Press DEL and you have only the XY plane polylines:
All curves are actually tens of joined straight lines:
Select all and save as SVG. I opened the result in Inkscape and gave to it red stroke to make it visible. Here it is:
I have no idea if a cutter accepts it. I have only sent DXFs to a cutter. The "cutter" I wrote was a person who operated the laser cutting machine. He threw out everyone who seemed to think to input something to the machine without him.
I wrote "fight with a CAD". That's because you must probably work hours before you have a CAD program installed and you have learned how to set projections and make selections.
Good luck!
Any decent CAD app will open an STL, and you should be able to set up an orthographic projection and export or save out as SVG.
Heck, you could do this with Blender, or OnShape... or even Draftsight or FreeCAD I think - and all of these are freeware.
Blender includes freestyle which can draw outlines based on various settings, the default settings include a silhouette which should suit your needs. Once your render includes freestyle lines you can use the Freestyle SVG exporter.
While I am not sure it will fit your needs, you may want to look at blenderCAM, which generates g-codes for CNC machines. I think so far it still only supports milling machines, looking through the project forks may find someone working on supporting other machines.
You can also use Tinkercad (tinkercad.com) to import an .stl and export an SVG.
Here are a couple of tutorials:
https://mathgrrl.com/hacktastic/2019/09/laser-cutting-from-a-3d-file/ https://community.glowforge.com/t/convert-stl-to-svg-with-tinkercad/33766
Atomic compiler (www.atomiccompiler.com) can slice an .STL to an .SVG or a .DXF. You have to write some lines of code to tell it exactly what you want to do, however, if you look in the tutorial page you can basically copy and paste a few lines and change a few variables.