Here is one variation of an iLogic rule that will export the main assembly, and each of the referenced model files within out to STEP files. It saves the new STEP files to the same location the model file is at, and gives them the same file name as the model file, except the file extension is now ".stp". It also sets most of the settings within the translator to certain values. You may want to change those if they don't meet your needs.
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
oAssemSTEP = System.IO.Path.ChangeExtension(oADoc.FullFileName, ".stp")
ExportToSTEP(oADoc, oAssemSTEP)
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
'only export it to STEP if it's either an Assembly or a Part
If oRefDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject And _
oRefDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
Continue For
End If
oNewName = System.IO.Path.ChangeExtension(oRefDoc.FullFileName, ".stp")
ExportToSTEP(oRefDoc, oNewName)
Next
End Sub
Sub ExportToSTEP(oDoc As Document, oNewFullFileName As String)
'get the STEP translator Add-in
Dim oSTEP As TranslatorAddIn
For Each oAddIn As ApplicationAddIn In ThisApplication.ApplicationAddIns
If oAddIn.DisplayName = "Translator: STEP" Then
oSTEP = oAddIn
End If
Next
If IsNothing(oSTEP) Then
MsgBox("STEP Translator Add-in not found. Exiting.", vbCritical, "iLogic")
Exit Sub
End If
'create needed variables for translator
oTO = ThisApplication.TransientObjects
oContext = oTO.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = oTO.CreateNameValueMap
oDataMedium = oTO.CreateDataMedium
'Check to see if the STEP file already exists, if it does, ask if you want to overwrite it or not.
If System.IO.File.Exists(oNewFullFileName) Then
oAns = MsgBox("A STEP file with this name already exists." & vbCrLf &
"Do you want to overwrite it with this new one?",vbYesNo + vbQuestion + vbDefaultButton2, "STEP FILE EXISTS")
If oAnswer = vbNo Then Exit Sub
End If
oDataMedium.FileName = oNewFullFileName
If oSTEP.HasSaveCopyAsOptions(oDoc, oContext, oOptions) Then
' Set application protocol.
' 2 = AP 203 - Configuration Controlled Design
' 3 = AP 214 - Automotive Design
oOptions.Value("ApplicationProtocolType") = 3
oOptions.Value("IncludeSketches") = True
oOptions.Value("export_fit_tolerance") = .000393701 'minimum
oOptions.Value("Author") = ThisApplication.GeneralOptions.UserName
oOptions.Value("Authorization") = ""
oOptions.Value("Description") = iProperties.Value("Summary", "Title")
oOptions.Value("Organization") = iProperties.Value("Summary", "Company")
Try
oSTEP.SaveCopyAs(oDoc, oContext, oOptions, oDataMedium)
Catch
MsgBox("Your attempt to export this document as a STEP file FAILED!", vbOKOnly + vbExclamation, "Export to STEP Error")
End Try
End If
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)