I want to export with the filename of the part, but it's doesn't work.
Below my macro VBA, stopped at "FileName = oDocument.FullFileName"
Sub ExportToSTEP()
' Get the STEP translator Add-In.
Dim oSTEPTranslator As TranslatorAddIn
Set oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
If oSTEPTranslator Is Nothing Then
MsgBox "Could not access STEP translator."
Exit Sub
End If
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
Set oOptions = 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 = kFileBrowseIOMechanism
'Set filename as original document filename.
Dim FileName As String
FileName = oDocument.FullFileName
Dim Temp() As String
Temp = Split(FileName, "\")
FileName = Left(Temp(UBound(Temp)), Len(Temp(UBound(Temp))) - 4)
'Set the destination to save files.
Dim oDocRevision As Property
Dim Revision As String
Set oDocRevision = oDocument.PropertySets.Item("Inventor Summary Information").Item("Revision Number")
If oDocRevision.Value = "" Then
oDataMedium.FileName = "C:\Users\amn\Desktop\" & FileName & ".stp"
Else
Revision = "_" + CStr(oDocRevision.Value)
oDataMedium.FileName = "C:\Users\amn\Desktop\" & FileName & Revision & ".stp"
End If
Dim oData As DataMedium
Set oData = ThisApplication.TransientObjects.CreateDataMedium
'Publish document.
Call oSTEPTranslator.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End If
End Sub