Hi @FeelGoodGirl. Here is a different version of the code to export the drawing's model out to a STEP file you can try. This attempts to save the STEP file with the same path & file name as the model, but with the ".stp" file extension.
Sub Main
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.", vbCritical, "iLogic")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
'get the 'Model' document
If oDDoc.AllReferencedDocuments.Count = 0 Then
MsgBox("This drawing is not currently referencing any other documents. Exiting.", vbInformation, "iLogic")
Exit Sub
End If
'Dim oModel As Document = oDDoc.AllReferencedDocuments.Item(1)
For Each oModel As Document In oDDoc.AllReferencedDocuments
If oModel.DocumentType = DocumentTypeEnum.kPartDocumentObject Or _
oModel.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
'run our custom Sub below on it
ExportToSTEP(oModel)
End If
Next
End Sub
Sub ExportToSTEP(oModelDoc As Document)
'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
'specify full file name of new STEP file it is to create
'this will keep full path & file name of model, but with ".stp" file extension
oNewFile = System.IO.Path.ChangeExtension(oModelDoc.FullFileName, ".stp")
'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(oNewFile) 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 = oNewFile
If oSTEP.HasSaveCopyAsOptions(oModelDoc,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") = oModelDoc.PropertySets(3).Item("Description").Value
oOptions.Value("Organization") = oModelDoc.PropertySets(2).Item("Company").Value
Try
oSTEP.SaveCopyAs(oModelDoc, oContext, oOptions, oDataMedium)
Catch
MsgBox("Export drawing Model to STEP file - FAILED!", 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)