3D part design with OpenSCAD and Freecad #156: Step by step guide to converting an .stl file to a .step file.
Being based on a CSG kernel OpenSCAD doesn't save .step files which are sometimes needed for exchanging files with other people and various other reasons, this isn't a limitation of OpenSCAD it is just not practical to re-write an entire kernel and it's not necessary because there are tools like Freecad that can convert an .stl file generated with OpenSCAD to a .step file with a macro in just a few seconds.
Here is a step by step guide on how to do this:
I am using the latest development build of OpenSCAD and FreCAD 1.1.1

Step 1 > After FreeCAD is loaded make sure you are in the "Part" workbench

Step 2 > Go to File> Create new document:

Step 3 > Click on the Open document icon and import the .stl file


Step 4 > After the file loads select the object in the tree on the left hand side and it will highlight blue then go to Part> Shape from Mesh to convert it to a shape.

Step 5 > In the dialog that pops up click "sew shape" , set the tolerance to .10 and click ok.

Step 6 >A new object will be created in the tree, make sure it is selected then go to Part>Copy>Refine Shape

Step 7 > Another new object will be created in the tree, select it and go to Part>Convert to Solid

Step 8 >Another new object will be created in the tree, select it, change the work bench to the "Part Design" workbench and click on the new body Icon ( the blue steps icon):

Step 9 > a new object will be created in the tree, select "BaseFeature":

Step 10 > Then go to File>Export:

Step 11> Enter the file name and select "Step with colors" as the file type:

Step 12> A dialog will pop up allowing you to select the .step units and scheme:

The file will be saved. I always put the files on my desktop in a working folder so it's easy to find, then I reload it into free cad to make sure everything looks good.
This might seem like a lot of work but after you do it a couple of times it's pretty easy to convert a file. Luckily FreeCAD has the ability to record macros which will allow you to record the steps and then just run a macro to automate the process the next time.
Note: you have to name the stl file with the same name each time and open it from the same location when you run the macro, I named mine "untitled.stl" and keep it on the desktop so it's easy to find. It usually takes about 6 seconds to run the macro for me.

