Working with STL and OBJ Files

This posting isn’t about how to use the API but is an example of what can be done with the API and hopefully is useful to some of you.  A big reason I’m posting it here is that I continue to get requests for the program and this will provide a better way to distribute and update it than the newsgroup.

The program came about after I visited a university a couple of years ago that is using Inventor as part of their engineering program.  In one of their classes the students need to create an Inventor model to fit around a model that’s defined by an OBJ file.  (OBJ and STL files are formats that define a model using a mesh of triangles.)  It was difficult for them to use this data in Inventor and it seemed to me like something could be done to improve the process and it became a pet project of mine.

The Facet Enabler add-in became the result.  It’s an add-in that uses client graphics and client features, plus a lot of code of my own.  It allows you to read in an OBJ or STL file and see it in Inventor.  What you see is just client graphics which means it’s only for display and doesn’t affect the model and can’t be used for other operations like interference checking, measure, etc.  To be able to make use of the mesh data for modeling the add-in supports a command that lets you cut a section through the client graphics, which creates a sketch that can then be cleaned up and used as input for standard Inventor features.

The add-in adds two commands to Inventor.  The first is added to the part environment.  Its icon is the yellow pyramid as shown below (the second to the last command in the panel bar).  If using the ribbon interface it is in the Add-Ins panel of the Part ribbon.  When you read in the OBJ or STL data a new icon is created in the browser to represent the data.  There are also several options to control how it is displayed that are accessed from the context menu, as shown below.  (The “Smooth Shading” option is only available if that information existed in the OBJ file.  It’s never available for STL data.)

FacetEnablerOptions

In the sketch environment there’s one new button that’s added.  It looks like a sectioned pyramid and is the last command in the panel menu below.  It will create sketch geometry that represents a section cut through the faceted model as shown below.  You can use the sketch geometry for standard Inventor modeling.

FacetEnablerSection

To install the program just download the zip file and run the install program it contains.  It will run with Inventor 2009 and later.

Facet Enabler Install Download

Please let me know if you find any problems, have suggestions to improve the program, or want to be notified if there are updates.  I’ll also update this blog post when I update the program.

Revisions
July 14, 2009 – Initial Post
July 23, 2009 – Posted version 1.5 which contains a fix to correctly handle line continuation characters in OBJ files.


Comments

11 responses to “Working with STL and OBJ Files”

  1. Brian,
    Neat! Just a small FYI. At SYCODE (www.sycode.com) we offer Inventor add-ins that import STL and OBJ (among other mesh formats) to Inventor parts as solid objects (not client graphics) that can be edited using Inventor’s solid modeling tools.
    I hope this does not sound like advertising. Well, who am I kidding. It is, isn’t it. ;-)
    Cheers!

  2. Hi Brian E.,
    This is interesting to me. I have an interest in hi-def, phase shift scanners (i.e. FARO, Leica, etc.) and there is a large gap between obtaining the scan data (point clouds) and being able to utlize that data inside Inventor (cost effectively). I am VERY new to programming and the API of Inventor, so please excuse any ignorant questions. Could this add-in be extended to bring in “point clouds” as client graphics for which that data could also be leveraged in a 2D sketch? Also, did you make the OBJ & STL files be displayed as client graphics to keep it light weight? TIA!!
    -Brian Hall

  3. Hi
    Excellent add-in, thanks for sheering and hope this add-in is integrated in the new version of Inventor.

  4. Hello Brian,
    i tried it with a german installation and it doesn’t work. Furthermore i couldn’t import step untill i uninstalled our programm.
    Is there a possibility to get it in a version, that works with a german installation ?
    For your information: I have installed INV2008 and INV2010 Prof. and tried your tool with INV2008.

  5. Wonderful post… Very educational and easy to understand. Thanks for the excellent post!

  6. animation clips Avatar
    animation clips

    thanx that you post this article on our request

  7. As anybody understands respect is one of the most imperative amongst people’s existence. Only respect one another to obtain along properly and I feel that leaving one’s opinion is often a behavior of respect. Do you feel so?

  8. I think it’s just great what you did! I is fascinating how sometimes the most random things give us inspiration to do something wonderful!

  9. JSP 3D.C.S Avatar
    JSP 3D.C.S

    Hi Brian, thanks for the facet enabler for AIP 2011, works well! However I have a client having issues not opening .stl file that I can. I have told him to uninstall and reinstall but no luck there either, are there any tricks to uninstalling apart from add/remove progs etc?
    Thanks

  10. Hi Brian, thanks for the facilitator facet of AIP 2011, works fine! However I have a client that has no problems opening the file. Stl I can. I have told to uninstall and reinstall but luck does not exist or is there some trick to uninstall as well as add or remove progs etc who wants to learn to fly one day must first learn to stand, walk and run and climb and dance? , can not fly in flight. Nope. This is not my own project. I finish it in a teamwork, so we spare the job in every of us.

  11. Brian, this API, even with all the limitations you stated so clearly, has just saved my project (not an academic one). The STL visualization and on-plane cross sections was exactly what I needed. I usually used the SYCODE which works smoothly but I think it’s a high price to pay for a functionality that SHOULD be provided by the software.
    The day Inventor takes seriously STL & Scan data, that day it will take the edge over its competitors.

Leave a Reply to Pet monkeys for saleCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading