Importing a STL file

 Since there are so many 3D files on the net that are in STL format, I checked to see if I could import them into BricsCAD (I have v14 Platinum . Unfortunately, BricsCAD will only export a STL file, no import.

Is there a utility someone can recommend for importing directly, or perhaps a free3rd party program that can convert it to something like IGES that BricsCAD can import?

-Joe

Comments

  • Hello Joe,
    STL is a very 'dumb' mesh format made up from non-interconnected facets (no shared vertices).
    Importing into BricsCAD is therefore of limited interest, but if you want it anyway:

    - download a copy of blender (a must-have anyway)
    - activate STL-import and dxf export (under file/user preferences/import-export)
    - import your STL model
    - select it (hint: blender default is with the right mouse button) and press TAB to go into edit mode
    - type A (maybe repeatedly) to make sure all vertices are selected
    - type W and select 'remove doubles' from the pop-up menu (I think the importer does this automatically, but just to make sure)
    - type ALT-J to join triangles into quads as far as possible
    - press TAB to exit edit mode
    - select export/dxf from the file menu
    - choose Export Mesh as POLYFACE in the options
    - write the dxf and open it in BricsCAD
  •  I actually tried to use Blender. I even just updated it to the most current stable version, but was disappointed to find that it does not import/export DWG or DXF.  In fact, there is no common format between the two programs.

    How is it that you have a DXF export ability?

    -Joe
  • Hello Joe,
    Blender is opensource software primarily intended for CG/VFX, and nobody in this community gives a damn about dwg.
    However, Blender does support dxf - the legacy series (up to 2.49) even had a very good importer (written by Migius), but the current series comes with very crippled dxf support out of the box (a more capable one is available on subscription here).
    Still, the built-in exporter is able to convert a blender mesh to a polyface mesh in dxf-format (for an example, look at the attached dxf - the part has been exported from BricsCAD as STL, then converted to dxf with Blender's built-in exporter).
    As I said, since Blender comes with a long list of optional modules, you have to enable the functionality you need by opening User Preferences / Addons and choosing the respective add-on from the list (Both 'STL format' and 'Export Autocad DXF Format' are found under 'Import-Export').
    I understand that Blender is a frightening program for new users, but the advantage of using it over a simple converter is that it allows you to clean up the model and split/combine it as you need before importing into BricsCAD.

    stl-dxf.zip

  • There is a good news... you can import STL into your BricsCAD editor with an extension application:

    https://www.bricsys.com/common/applications/application.jsp?app=685&apploc=1126

    Feel free to import your STL model into DWG and export it to IGES, BREP, STEP and many other 3D file formats.

    http://www.automapki.com/products/automesher-application.html

  • Hello Joe,

    i have used MESHLAB with success most times !
    You can import STL, OBJ, 3DS and many other formats and export DXF ...
    You should try it

    http://sourceforge.net/projects/meshlab/files/meshlab/MeshLab v1.3.3/

    http://meshlab.sourceforge.net/
  • Hi Konstantin,
    Yes, Meshlab is another must-have tool, but I have to say I found it no less demanding than blender, mainly because of the lack of documentation...

    To characterize them, I'd say: Meshlab sits on the scientific end and has its strength in automatic mesh-editing, while Blender sits on the artistic end and has its strength in manual mesh-editing (apart from its incredibly vast other capabilities, of course).
  • Thank you all for the replies. 

    Here is a screen grab of my Blender export menu.  It does not show any DXF options.  This is version 2.70a. Is there a different menu that shows the DXF export ability?

    -Joe


    imageMesh 2p7 Export options.png
  •  I just tried Meshlab.  All I did was import the STL mesh and then export it as a DXF. The operation was very straightforward, at easier than using Blender itself, since Blender's file dialog boxes do not operate like Windows programs.

    As expected, the mesh was a series of disconnected faces, but for my needs, for now, it was sufficient.

    For future reference, does anyone know if Meshlab is able to automatically turn a collection of faces into a polyface mesh and/or automatically reduce the number of faces?  As others have noted, documentation is poor, so I thought it wise to ask if it is possible before I go on a wild goose chase.

    -Joe
  • Hello Joe,

    I think your screenshot just shows the exporters activated by default. As mentioned earlier, Blender ships with a quite extensive choice of add-ons that you have to enable as needed, and im-/exporters make no exception.

    So, to activate dxf export, you would have to choose 'User Preferences' from the file menu, and click on 'Addons'. Initially, only add-ons that are regarded as 'Official' might display, so (under 'Supported Level') enable 'Community' and 'Testing' as well (dxf-export is in fact tagged as 'Community'). If you then type dxf in the search box in the top left corner, only dxf im- and export should display, and have to be enabled.

    That said, it might of course be more straightforward to use Meshlab - but I did not succeed in rather simple editing of imported meshes, e.g. the 'tri to quad' filter reported success, but I could not spot any difference on the model. So I for now only used it when blender failed to import some file (especially .dae), and for this, it worked very well.

  • Hi Joe,

    you can find many lisp routines in the web to convert a set of 3Dfaces to a polyface mesh (PfaceMesh)...
    Here is one and in the attachment. I tested it and it works fine.
    http://www.cadtutor.net/forum/showthread.php?64035-covert-3d-face-to-polymesh
    Just load the routine with (load "MakPface.lsp") and use the command   MakPface  to select the 3Dfaces you want to convert.

    You can also use my plugin to convert a set of 3Dfaces into ACIS  surfaces and solids as described here:
    https://forum.bricsys.com/discussion/17053#23550
    have a look at post #89

    [code]
            ;=======================================================================
            ;    MakPface.Lsp                               Sep 19, 1998
            ;    Make A PFace Mesh From A Selection of 3DFaces
            ;================== Start Program ======================================
            (princ "\nCopyright (C) 1998, Fabricated Designs, Inc.")
            (princ "\nLoading MakPface v1.5 ")
            (setq mpf_ nil lsp_file "MakPface")

            ;================== For Automated Calling From Another Program =========
            (defun mpf_auto (ar1) (fa2pf ar1)) ;;;Supply PickSet Of Faces

            ;================== Macros =============================================
            (defun PDot ()(princ "."))

            (PDot);++++++++++++ Set Modes & Error ++++++++++++++++++++++++++++++++++
            (defun mpf_smd ()
             (SetUndo)
             (setq olderr *error*
                  *error* (lambda (e)
                            (and (/= e "quit / exit abort")
                                 (princ (strcat "\nError: *** " e " *** ")))
                            (command "_.UNDO" "_END" "_.U")
                            (mpf_rmd))
                   mpf_var '(("CMDECHO"   . 0) ("MENUECHO"   . 0)
                             ("MENUCTL"   . 0) ("MACROTRACE" . 0)
                             ("OSMODE"    . 0) ("SORTENTS"   . 119)
                             ("BLIPMODE"  . 0) ("MODEMACRO"  . ".")
                             ("SNAPMODE"  . 1) ("PLINEWID"   . 0.0)
                             ("ORTHOMODE" . 1) ("GRIDMODE"   . 0)
                             ("ELEVATION" . 0) ("THICKNESS"  . 0)
                             ("FILLMODE"  . 0) ("SPLFRAME"   . 0)
                             ("UCSICON"   . 1) ("HIGHLIGHT"  . 1)
                             ("REGENMODE" . 1) ("COORDS"     . 2)
                             ("CECOLOR"   . "BYLAYER") ("CELTYPE" . "BYLAYER")))
             (foreach v mpf_var
                  (setq m_v (cons (getvar (car v)) m_v)
                        m_n (cons (car v) m_n))
                  (setvar (car v) (cdr v)))
             (princ (strcat (getvar "PLATFORM") " Release " (substr (ver) 18 2)
               " -  Make PFface Mesh ....\n"))
             (princ))

            (PDot);++++++++++++ Return Modes & Error +++++++++++++++++++++++++++++++
            (defun mpf_rmd ()
              (setq *error* olderr)
              (mapcar 'setvar m_n m_v)
              (command "_.UNDO" "_END")
              (prin1))

            (PDot);++++++++++++ Set And Start An Undo Group ++++++++++++++++++++++++
            (defun SetUndo ()
             (and (zerop (getvar "UNDOCTL"))
                  (command "_.UNDO" "_ALL"))
             (and (= (logand (getvar "UNDOCTL") 2) 2)
                  (command "_.UNDO" "_CONTROL" "_ALL"))
             (and (= (logand (getvar "UNDOCTL") 8) 8)
                  (command "_.UNDO" "_END"))
             (command "_.UNDO" "_GROUP"))

            (PDot);====== Convert A Selection Set Of 3DFaces To A PFace Mesh =======
              (defun fa2pf (ss / slen i ed en ef vlist vlen tlist ln)
              (and (/= (type ss) 'PICKSET)
                   (princ "** Invalid Parameter To FA2PF ** ")
                   (exit))
              (princ "\nDetermining Vertex Data\n")
              (setq slen (fix (sslength ss))
                       i (1- slen))

            ;;;LAYER NAME
              (setq ln (cdr (assoc 8 (entget (ssname ss 0)))))

              (while (>= i 0)
                  (setq en (ssname ss i)
                        ed (entget en)
                         i (1- i))
                   (and (/= (cdr (assoc 0 ed)) "3DFACE")
                        (princ "\n** 3DFACES Only ** ")
                        (exit))
                   (foreach g '(10 11 12 13)
                          (if (not (member (cdr (assoc g ed)) vlist))
                              (setq vlist (cons (cdr (assoc g ed)) vlist))))
                   (princ (strcat "\r" (rtos (/ (* 100 i) slen) 2 0) "% ")))
              (princ "\nDetermining Face Data\n")
              (setq vlen (length vlist))
              (entmake (list (cons 0 "POLYLINE")
                             (cons 8 ln)
                             (cons 10 (list 0 0 0))
                             (cons 66 1)
                             (cons 70 64)
                             (cons 71 vlen)
                             (cons 72 slen)))
              (foreach v vlist
                 (entmake (list (cons 0 "VERTEX")
                                (cons 10 v)
                                (cons 70 192))))
              (setq i (1- slen))
              (while (>= i 0)
                (setq en (ssname ss i)
                      ed (entget en)
                      ef (cdr (assoc 70 ed))
                       i (1- i)
                   tlist nil)
                (foreach c '(1 2 3 4)
                  (setq tlist (cons
                    (cons (+ 70 c)
                          (* (if (= (logand ef (expt 2 (1- c))) (expt 2 (1- c))) -1 1)
                             (1+ (- vlen (length (member (cdr (assoc (+ 9 c) ed)) vlist))))))
                        tlist)))
                (entmake (list (cons 0 "VERTEX")
                               (cons 8 ln)
                               (cons 10 (last vlist))
                               (if (assoc 62 ed)
                                   (assoc 62 ed)
                                   (cons 62 256))
                               (cons 70 128)
                               (nth 0 tlist)
                               (nth 1 tlist)
                               (nth 2 tlist)
                               (nth 3 tlist)))
                 (princ (strcat "\r" (rtos (/ (* 100 i) slen) 2 0) "% ")))
              (entmake (list (cons 0 "SEQEND")(cons 8 ln)))
              (command "_.ERASE" ss "")
              (redraw (entlast)))

            (PDot);************ Main Program ***************************************
            (defun mpf_ (/ m_v m_n olderr mpf_var ssface)
              (mpf_smd)
            ;  (setq *error* nil)
              (setq ssface (ssget '((0 . "3DFACE"))))
              (fa2pf ssface)
              (mpf_rmd))

            (PDot);************ Load Program ***************************************
            (defun C:MakPface () (mpf_))
            (if mpf_ (princ "\nMakPface Loaded\n"))
            (prin1)
            ;================== End Program ========================================
            ;Tested With R12_c3 DOS & R13_c4a Only
            ;Copyright (C) 1998, Fabricated Designs, Inc.
            ;"AS IS" Public Domain Software Donated By
            ;
            ;
            ;        Fabricated Designs, Inc.
            ;        32 Maury Avenue
            ;        Newport News, Virginia  23601-2132
            ;         Ph: (757) 595-5949
            ;        FAX: (757) 595-5787
            ;        CIS: 73544,2655
            ;   Internet: http://ourworld.compuserve.com/homepages/DavidBethel/
            ;

    [/code]

    MakPface.Lsp

  •  Thanks again for the very helpful replies.  and especially Knut for the details about getting the DXF in/export working in Blender.  I searched on the forum for DXF export, but it did not describe what you just did.  I also searched for ways to reduce the polygon count of a dense mesh from the STL I used, but while there seems to be a feature built in for that, the manual does not describe how to get it working in the current version.

    -Joe
  • Hello Joe,
    glad it helped.
    In Blender, polygon count reduction is done via a modifier called 'Decimate'.
    The advantage of modifiers is that you can freely alter their settings without altering the base geometry, until you hit the 'Apply'-button.
    The 'Decimate'-modifier offers three different algorithms (Collapse|Un-Subdivide|Planar), but all of them work better on dinosaurs than on mechanical parts... but see for yourself: attached is the blender file with the STL from my last example read in, with an active collapse modifier with 0.2 ratio already set-up. This brings the face count down from 4872 to 1413, but the quality of the model suffers significantly, even with less aggressive settings (you can toggle the modifier with the small eye symbol). On input that is already kind of degenerate, the results may be fine, though.

    STL.blend

  • In Blender, polygon count reduction is done via a modifier called 'Decimate'.

    I am going to take this particular branch of the thread to the thread titled, "Anyone with experience in 3D scanning? "

    -Joe
This discussion has been closed.