Thursday, 30 May 2013

STL to STEP with FreeCAD ...

A couple of months ago, I used InStep V2.0 by Solveering to convert STL files to STEP files, in order to obtain solid models for modification in my favorite CAD package. Whilst CAD model conversion should always be treated with caution. When it works, it can help create a new model more easily or save some time and effort.
FreeCAD STL to STEP solid of Thing 64549

Following a comment posted in the STL to STEP blog entry. I decided to try FreeCAD 0.13. As my CAD program is over 10 years old, it's about time I moved to something a little more modern. The stumbling block has always been import / export capability. Ease of use and graphics capability were additional considerations, but time has leveled the playing field somewhat where graphic rendering is concerned. The ultimate platitude usability is still a worry, though most modern packages seem to exhibit wrinkles now rather than show stopping user interface 'faux pas'.

Packages such as Tinkercad, Creo and the like are frequently crippled quite severely. Usually so as not to detract from some other market segment product being purveyed. Typical limits include import / export format limitations and resolutions. Or limited numbers of features allowed in the part, limited assembly components or limited capabilities e.g Splines, Surfaces etc. Creo, demanding to see a license server on the internet every 3 days. Assumes I care to expose my CAD computer to the internet. Whilst I have no designs in the 'top secret' category. When out and about, the necessity of using public internet to refresh the license; potentially 'creating backdoor access holes' for third parties; is not something I wish to do where possible. At the other extreme, Tinkercad's birth has been somewhat ignominious.

I decided the acid test for any candidate CAD software, was the ability to take an STL file from Thingiverse and create a solid model ready for subsequent modification. At this stage only and import export functions are important; with a view to migrating over time to native modelling.

The crunch test seemed to be the Thing 64549 which crashed Instep V2.0. It has a lot of points associated with the spiral and cylinder features, around 63900 apparently. So this is the first model I decided to try out  with FreeCAD.

FreeCAD handles STL files using a family of functions grouped under 'Mesh Design'. Interestingly FreeCAD also has some basic Mesh fix up functions. However for the test I decided to rely on files previously manipulated in NetFabb.

The two screens below show Thing 64549 imported as a Mesh, converted to a solid, exported as a STEP file and finally imported back into FreeCAD. I failed to get a valid file from Instep which was allowed to run overnight. FreeCAD took somewhat less time and managed to produce a usable file, though a little large at 160Mb.

Import of Thing 64549 STL and conversion to solid

Import of FreeCAD STEP file

Here is a quick summary of how the conversion process is performed in FreeCAD 0.13. The example shown is based on a Raspberry PI case modified previously.

Initial FreeCAD screen with Mesh functions selected

Imported STL Mesh

Selecting the FreeCAD Mesh fix up tools

FreeCAD mesh fix up tools

FreeCAD conversion of mesh to solid in the Part functions

FreeCAD solid conversion tolerance parameter (left as standard)

Converted mesh now as solid (notice extra entry in the Tree View)

Exporting the Solid as a STEP file (Select FILE the EXPORT from the menu)
For the Rapsberry Pi case InStep seems to produce a smaller STEP file and this may or may not better represent the geometry than FreeCAD. The price performance balance seems to favor FreeCAD and if it is less efficient, it has some performance benefits, in that it converted Thing 64549.

24 comments:

  1. thanks! very good tutorial..

    ReplyDelete
  2. Thanks a lot :-) You really helped me out.

    ReplyDelete
  3. Thanks for evaluating FreeCAD following my comment! I recommend adding two more steps (pun unintended :-P) to the procedure. The "Create shape from mesh" tool does *not* produce a solid, but a shell. You have to select the produced shape, then go to Part --> Convert to solid. Now you got a real solid. Optionally, you can then select the solid and go to Part --> Refine shape. This runs a tool that cleans up the model by joining all the little planar faces which were facets of the mesh.

    ReplyDelete
    Replies
    1. During conversion how do you know if it has crashed or is still computing? Even after waiting overnight mine is still hanging and not responding.

      Delete
    2. Hi, of course it depends on model complexity and processing power.
      First I usually look at the memory and disk use. If these are constant for some time, I find its likely the code has locked up in some kind of loop. Additionally when you have processed a few hundred models you get a feel for the complexity and how long it should take. A simple rule of thumb can be obtained by looking at the number of facets in the model.

      Watch out as STL's can be quite 'buggy' so make sure you clean or fix it up if first. It should at least be 'manifold' (a 'watertight' object). There are some pointers here http://northernhope.blogspot.co.uk/2012/09/stl-to-step.html. Netfabb is a must. I might even write an article on fixing STL's, but 'one might be walking where angels fear to tread'. Good luck.

      Delete
  4. Thanks very much, It post save my work,

    ReplyDelete
  5. thanks a lot for your tutorial. I still have troubles creating a solid from my stl file (~20MB of size) which is derived from a microCT scan. It is very complex structure (porous ceramic) and I think this is where the problem starts. I cleaned the structure until was manifold but whean I want to create a soli FreeCAD turns instantly into "Not Responding"-mode. I left it like this for hours but it never gave a result. Is it normal that it takes such a long time for computing?
    Do you have any suggestions an what to do?
    I need this structure as real solid for further analysis in COMSOL Multiphysics. When I tried to import the stl file in COMSOL it stated "file cannot be parameterized".

    Do you think a more powerful processor can do the trick?

    thanks in advance for your help!!

    ReplyDelete
    Replies
    1. You probably have way to much information in the mesh for the production or analysis method. It's something I see a lot. To clean and simplify your mesh you might try Meshlab. See the associated article http://northernhope.blogspot.co.uk/2012/09/stl-to-step.html for a very quick example.
      It's a power full open source tool that can cut your mesh to size. The trick is understanding what you need, to have the model still make sense in the target application.

      Delete
  6. How can I convert a stl file to iges

    ReplyDelete
    Replies
    1. Select IGES (*.iges, *.igs) from the export menu rather than STEP.

      Delete
  7. Hurray for FreeCAD! Although with a lot of triangles, it really works!

    ReplyDelete
  8. A very useful tutorial ... it could provide a link to a tutorial regarding mesh repair (fixing holes) using Netfabb Basic, though.
    I'm in the process of converting an object with 335k vertices now which makes FreeCAD quite unresponsive (Ubuntu 14.04).

    I guess when it comes to real work - some ten million vertices - I'll loose my patience. Either during FreeCAD processing or while re-importing the STEP file. Maybe the computer does it for me ... poop - program gone without any notice (core dump).

    The Creo predecessor Pro/E 2001 does import STL files, even shows a 3D shaded object - but no way of manipulating it.
    Or if there is, I didn't manage to find out in ten years. So a good STL2STEP procedure is pretty important.

    ReplyDelete
  9. One of the most useful articles i've read so far about how to create STL files. It's obvious that you know what you are talking about, and seem to really love what you do.

    However, i would like to ask if you have any experience with actually 3d printing files and if yes, would you be interested to make a headline bout it.

    ReplyDelete
    Replies
    1. Hi, check out the rest of the Blog, there are some lessons learnt on 3D printing together with some descriptions and thoughts on designs I thought might be generally interesting to others.

      Delete
    2. @Conseils, thanks, I'm already checking, great job!

      Delete
  10. That worked very well. Thank you for posting the process for us neophytes!

    ReplyDelete
  11. Hi. I have a not very complex (4,606 face) STL file that I need to get converted to a step file for CNC production. My CNC guy said the following;

    "So we need it possibly redrawn.
    STL and OBJ files make the geometry out of loads of little flat surfaces (polygons).
    CNC machines cannot work with these, they need smooth paths to machine along.
    (image of my part which does indeed have lots of little triangles)
    See the image above? It shouldn't have all those lines. It treats all those trianlges as a individual surfaces to machine."

    Is there a way to fix this or is it a case of "you can't get there from here"?

    ReplyDelete
    Replies
    1. In short he / she is right, the question is does it matter?

      In essence the "Design intent" has been removed, lost in the STL export process if an STL file is all you have. A 2D drawing or a solid model CAD file with suitable extensions conveys "Design intent" and assists in achieveing functionality. e.g. the tolerances and machining finishes are what your machinist wants. Typically a 2D drawing to BS 8888 / ISO equivalent.

      An STL file consists of flat facets, which would not normally be conveyed to a subtractive manufacturing technique such as a lathe or milling machining etc.

      Can you give him a STEP file, he will be able to work with that, however will still want a 2D drawing. Unless you give them carte blanche on tolerances (not generally a good idea)?

      You could import the STL as described and attempt to create a 2D dimensioned drawing from the imported file. However it might be easier to re-create the model from scratch. More importantly are the tolerance requirements to achieve the desired functionality and maintain manufacturability. Essentially a suitably toleranced drawing can significantly reduce manufacturing costs for subtractive manufacturing techniques.

      As additive techniques (e.g. 3D printing) have generally limited resolution, they tend to 'smooth' or loose much of the facet detail likely to be in an exported model. Subtractive manufacturing on the other hand often have very high precision. Facets not reproduced in 3D printing, will be attempted by a subtractive technique and often achieved.

      Next we need to look at the actual technique of manufacturing. If we consider 3D printing layers are often chosen based on the extrusion diameter and are typically in the range 0.05 to 0.5mm in height. Passing a milling cutter to make a box accross a face at these layer heights just doesn't make sense when and end mill can take 10's of mm's off per pass down the side of the box. Another expample is the direction of cutting with respect to rotational direction when using an End Mill matters, as cutting in the wrong way produces wind up in the machine and can break a cutter in some instances.

      I hope the brief summary is enough to help you understand what is worrying your machineist and how to get the best from them; sounds likey they are trying to do a good job for you.

      Delete
    2. If you are not familiar with what a 2D drawing look like:
      Check out this post:
      http://northernhope.blogspot.co.uk/2013/04/printing-test-objects-and-other-things.html
      You will see a 2D drawing of a complex 3D part. Notably you will see there are no tolerances on the drawing. This is as I never had the original model or the designers intent. The dimensioning is fairly complex. It's up to the manufacturer to decide in conjunction with that drawing and achived part what are acceptable deviations from the original model.

      Checking this post http://northernhope.blogspot.co.uk/2016/10/arduino-sealed-case.html
      Will reveal a very simple drawing with only the barest minimum of dimensions needed to understand how to deploy the unit.

      If I wanted these parts moulded I would have to add significant amounts of geometric tolerance information and probably a couple of sheets and views of the part.

      Delete