Here is a quick and easy way to get 2D DXF drawings extracted from 3D STL shapes using OpenSCAD. Launch OpenSCAD and enter the following:
Replace “/full/path/to/stl” with the path to your stl file, and hit F6 to compile and render using CGAL.
From the Design pull down menu choose Export as DXF.
The resulting DXF file as viewed in QCad is basic (circles are made from several straight line segments), but its good for making measurements or printing out templates.
You might find that you have to rotate the STL if you want to get a projection from a different side. You can also set cut=true if you want to cut the object using the XY-plane instead of projecting onto the XY-plane, if you do you will need to translate your object by a negative Z value. e.g:
projection(cut=true) translate([0,0,-10]) rotate([0,90,0]) import_stl("file.stl");
See the projection function in the OpenSCAD manual for more details.
10 thoughts on “Extracting 2D mendel outlines using OpenSCAD”
Ok dude, your awsome!
Thanks, thats exactly what I needed!
For some reason don’t succeed in exporting an STL file with the projection trick you outline. All I get are some 20 lines of headers in the dxf. What might I be doing wrong?
I am using OpenSCAD 2011.04.03 and the file present throuh svn at https://reprap.svn.sourceforge.net/svnroot/reprap/trunk/huxley/Cut-sheet-parts/y-chassis2_2.stl
Worked fine for me. You must be sure to press F6 (i.e. compile and render using CGAL) It will also take quite a long time: Total rendering time: 0 hours, 18 minutes, 53 seconds.
Here is the results: http://www.gilesbathgate.com/y-chassis2_2.dxf
Is there a way to get or set the scale of the plot? i.e. 1:1,or 2:1. I get DXF files with wildly varying scales and they are very difficult to print. I am using LibreCAD to visualise and do the printing.
By default OpenSCAD will treat the STL at a 1:1 scale. If you know what scale factor you want you can use:
projection(cut=false) scale([0.5,0.5,0.5]) import_stl("/full/path/to/stl");
You can read more about the scale operation in the openscad manual.
If you want automate creating DXF from STL parts, you may use bash-script in directory with STL files:
ls Slice-*.stl | while read r; do openscad -o "$r".dxf 1.scad -Dr=\"$r\"; done
Where the contents of the file1.scad:
projection(cut = false) import (str(r), convexity=3);
You are a lifesaver bro! This saved us countless hours of headaches trying to get dxfs from a modo file. Thanks a ton.