Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Exporting surfacebody to STL (solid or not)

Anonymous

Exporting surfacebody to STL (solid or not)

Anonymous
Not applicable

I'm attempting to export parts of a solid body as a surfacebody to STL. Using dataIO, the code that I tried to use was:

 

c# code:

 

Inventor.DataIO dataio = body.DataIO;
try
{
  dataio.WriteDataToFile("STL", "C:\tmep\testbody.stl");
}
catch
{
/* Additional information: Assert.Fail failed. System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at Inventor.DataIO.WriteDataToFile(String Format, String FileName)
*/ }

I'll admit my great ignorance for how to use the dataio object. I've not been able to export stl or step using this method, and I don't understand the error.

 

My end goal is to export the whole body as stl, and export different face combinations of the body as their own stl files. Is it possible with the current API? Do I have to use a translator instead of dataio? thanks for any help.

 

Edit: It appears that, perhaps, things will work out if I can define regions in the STL that I export. Is there a straightforward way to do this in inventor?

0 Likes
Reply
Accepted solutions (1)
932 Views
3 Replies
Replies (3)

Anonymous
Not applicable

Does Inventor simply not allow the exporting of surfaces to STL under any condition? I can work around this bug, but I would rather not force users to open a separate application just to split up an stl. Anyone have an idea?

0 Likes

Anonymous
Not applicable

I ended up writing my own stl translator for faces using GetExistingFacets/CalculateFacets methods.

0 Likes

ekinsb
Alumni
Alumni
Accepted solution

Fortunately the STL format is fairly simple so it's not too difficult to write an STL file.  I just saw your question and do have some information that will hopefully at least benefit someone else that finds this in a search. 

 

DataIO is very limited in the file formats it supports.  It doesn't support STL or STEP.  Instead of DataIO you can use one of the Inventor translators if you want to control all of the various options or if you're happy with the defaults you can just use the SaveAs method where the filename has the appropriate extension and the second argument is True to indicate you're doing a Save Copy As. 

 

The other option is to use the STL translator.  This is the same translator that's used when you interactively save an STL file and give you all of the various options to control the output mesh.  One limitation with both Save Copy As and the STL translator is that Inventor always writes out the entire part.  You can't specify a specific body.  A workaround to this is to copy the desired body into another part so it's the only body and then export that part.  There are several samples in the API help that illustrate using the translator add-in interface.  Unfortunately, there aren't any that demonstrate exporting to STL but it's the same as the other types except the options are different.  You can find a list of the options in the API help.  If you search for "Translator Options" you'll find a topic with that same tiltle that lists all of the options for the translator add-ins.

 

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes