Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I try to make a bulk export of my .ipt part into .stl files with 1 .stl by Model State
But the problem is for 20 Model state, i get 4 "good" file, and 16 "1 Ko" files (bad file).
Sub Main Dim oDoc As PartDocument oDoc = ThisDoc.Document Dim oModelState As ModelState For Each oModelState In oDoc.ComponentDefinition.ModelStates Logger.Info(oModelState.Name) If oModelState.Name <> "Master" Then oModelState.Activate ExportSTL(oModelState.Name) End If Next End Sub Sub ExportSTL(ByVal oState As String) ' Get the STL translator Add-In. Dim oSTLTranslator As TranslatorAddIn oSTLTranslator = ThisApplication.ApplicationAddIns.ItemById("{81CA7D27-2DBE-4058-8188-9136F85FC859}") Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap oPath = ThisDoc.Path oFolder = oPath & "\MODEL_STATES_STL" 'Check for the STL folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If If oSTLTranslator.HasSaveCopyAsOptions(ThisDoc.Document, oContext, oOptions) Then oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium oData = ThisApplication.TransientObjects.CreateDataMedium oData.FileName = oFolder & "\" & ThisDoc.FileName(False) & "-" & oState & ".stl" oSTLTranslator.SaveCopyAs(ThisDoc.Document, oContext, oOptions, oData) End If End Sub
.
Solved! Go to Solution.