Thank You! This works perfect!
I didn't know where to start on this, and you gave me exactly what I wanted.
I made two changes, I am going to post here for other people.
I added the base document name to the exported filename path, and I added a line to got back to the primary model state after this export is done.
Dim oSTEPTranslator As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
Dim doc As PartDocument = ThisDoc.Document
Dim def As PartComponentDefinition = doc.ComponentDefinition
Dim folderDialog As New System.Windows.Forms.FolderBrowserDialog()
folderDialog.SelectedPath = System.IO.Path.GetDirectoryName(doc.FullFileName) ' "c:\temp\"
folderDialog.ShowDialog()
Dim folder = folderDialog.SelectedPath
For Each modelState As ModelState In def.ModelStates
ModelState.Activate()
' Get the STEP translator Add-In.
Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, 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 = ThisApplication.TransientObjects.CreateDataMedium
oData.FileName = System.IO.Path.Combine(folder, ThisDoc.FileName(False) & " - " & ModelState.Name & ".stp")
oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If
Next
ThisDoc.ActiveModelState = ThisServer.LanguageTools.CurrentPrimaryModelStateString