In Inventor 2013 the SaveAs method of the PartDocument by default creates binary format STL. Can I control output file format – binary or ASCII?
SaveAs method to translate files is very easy to use and supports a wide variety of formats but has limited flexibility with respect to controlling the various options when doing the translation.
Another approach takes advantage of the fact that translators in Inventor are implemented as a special type of Add-In. All translator Add-Ins are required to support a common set of methods and properties which allows you to write a program that drives the translator. The best resource for this information is the programming help.
Related link: Good overview on Inventor translators.
You may download here very useful utility developed by Brian Ekins. This utility writes a report that contains information about all of the loaded translators, their Add-In ID, and the options supported by each Add-In.
Here are Save Copy As options for export to STL:
Name Value Map:
ExportUnits = 4
Resolution = 1
AllowMoveMeshNode = False
SurfaceDeviation = 60
NormalDeviation = 14
MaxEdgeLength = 100
AspectRatio = 40
ExportFileStructure = 0
OutputFileType = 0
ExportColor = True
Option OutputFileType controls file format:
0 – binary, 1 – ASCII.
Public Sub ExportToSTL()
' Get the STL translator Add-In.
Dim oSTLTranslator As TranslatorAddIn
Set oSTLTranslator = ThisApplication.ApplicationAddIns _
If oSTLTranslator Is Nothing Then
MsgBox "Could not access STL translator."
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Save Copy As Options:
' Name Value Map:
' ExportUnits = 4
' Resolution = 1
' AllowMoveMeshNode = False
' SurfaceDeviation = 60
' NormalDeviation = 14
' MaxEdgeLength = 100
' AspectRatio = 40
' ExportFileStructure = 0
' OutputFileType = 0
' ExportColor = True
If oSTLTranslator.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
' Set accuracy.
' 2 = High, 1 = Medium, 0 = Low
oOptions.value("Resolution") = 1
' Set output file type:
' 0 - binary, 1 - ASCII
oOptions.value("OutputFileType") = 1
oContext.Type = kFileBrowseIOMechanism
Dim oData As DataMedium
Set oData = ThisApplication.TransientObjects.CreateDataMedium
oData.FileName = "C:\temp\Plate.stl"
Call oSTLTranslator.SaveCopyAs(oDoc, oContext, oOptions, oData)