- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When exporting an Assembly file within Inventor it can produce a STL for each occurrence (filename suffixed as per the DisplayName) with its Origin in the Master Assembly preserved (such that re-importing it all the parts are correctly positioned) when the 'One File per Part Instance' option is selected. Using the Translator via the API on a part file is fine but I cannot seem to get the Translator to replicate the behaviour when running the 'One File per Part Instance' command on an assembly using the API. As there is an option for this in the API translator I thought it might do this when it was enabled and offered an assembly but I cant get it work and how would it deal with the filenames?
If I recursively traverse the the assembly and all sub assemblies and export them individually the Origin position of each part within the assembly is lost.
There's lots of API information on using the STL Translator on Parts but I can find no examples on an IAM file - can anyone please point me in the right direction or provide a code snippet ?
Dim oDoc As Document = oInv.ActiveDocument
Dim oContext As TranslationContext = oInv.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap = oInv.TransientObjects.CreateNameValueMap
' Save Copy As Options:
' Name Value Map:
' ExportUnits = 4 , 5 = Millimeter
' 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
oOptions.Value("Resolution") = ComboSTLRes.SelectedIndex ' Set accuracy.0 = High, 1 = Medium, 2 = Low
oOptions.Value("OutputFileType") = 0 ' Set output file type:0 - binary, 1 - ASCII
oOptions.Value("ExportFileStructure") = ComboSTLStructure.SelectedIndex 'One part or multi ?
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oData As DataMedium = oInv.TransientObjects.CreateDataMedium
oData.FileName = STLPath & "\" & STLFileName & ".STL"
Call oSTLTranslator.SaveCopyAs(oDoc, oContext, oOptions, oData)
SBar1.Text = "Exported " & oData.FileName
oDoc.Close(True)
End If
Solved! Go to Solution.