You should Loop thru the modelstates, activate each modelstate and then do a save as Step
Here is a small sample:
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
ExportStep(oModelState.Name)
End If
Next
End Sub
Sub ExportStep (ByVal oState As String)
' Get the STEP translator Add-In.
Dim oSTEPTranslator As TranslatorAddIn
oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oPath = ThisDoc.Path
oFolder = oPath & "\Step"
'Check for the PDF 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 oSTEPTranslator.HasSaveCopyAsOptions(ThisDoc.Document, oContext, oOptions) Then
' Set application protocol.
' 2 = AP 203 - Configuration Controlled Design
' 3 = AP 214 - Automotive Design
oOptions.Value("ApplicationProtocolType") = 3
' Other options...
'oOptions.Value("Author") = ""
'oOptions.Value("Authorization") = ""
'oOptions.Value("Description") = ""
'oOptions.Value("Organization") = ""
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oData As DataMedium
oData = ThisApplication.TransientObjects.CreateDataMedium
oData.FileName = oFolder & "\" & ThisDoc.FileName(False) & "-" & oState & ".stp"
oSTEPTranslator.SaveCopyAs(ThisDoc.Document, oContext, oOptions, oData)
End If
End Sub