- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear Autodesk members.
I am trying to adapt my code to bulk export .STEP files from .iam documents and while doing this assign them the following name: Subject - Filename of .iam
When I use the following code my .iam-files are exported to .STEP-files, but the right name is not assigned as I want. Would it be possible to help me out?
Thank you very much on forehand!
Sub main()
Dim oSTEPTranslator As TranslatorAddIn
Dim oContext As TranslationContext
Dim oOptions As NameValueMap
Dim oDataMedium As DataMedium
Call ConfigureoSTEPTranslatorSettings(oSTEPTranslator, oContext, oOptions, oDataMedium)
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
'oFileDlg.Filter = "Inventor Files (*.iam)|*.iam"
oFileDlg.DialogTitle = "Delete Ilogic Rule in drawing"
oFileDlg.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.FullFileName ' ThisDoc.Path
oFileDlg.MultiSelectEnabled = True
'oFileDlg.FilterIndex = 1
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
MessageBox.Show("File not chosen.", "Dialog Cancellation")
ElseIf oFileDlg.FileName <> "" Then
For Each wrd In oFileDlg.FileName.Split("|") 'Words
Dim odoc As Document = ThisApplication.Documents.Open(wrd, True)
On Error Resume Next
oOptions.Value("FileName") = odoc.iProperties.Value("Summary", "Subject") & " - " & odoc.FileName(False)
oDataMedium.FileName = Left(odoc.FullFileName, (InStrRev(odoc.FullFileName, ".", -1, vbTextCompare) - 1)) & ".stp"
Call oSTEPTranslator.SaveCopyAs(odoc, oContext, oOptions, oDataMedium)
odoc.Close
Next
End If
MessageBox.Show("STEP-Export geslaagd. Proficiat! Je hebt zonet heel wat tijd uitgespaard! Groetjes, jullie programmeergenie Cor :)")
End Sub
Sub ConfigureoSTEPTranslatorSettings(ByRef oSTEPTranslator As TranslatorAddIn, ByRef oContext As TranslationContext, ByRef oOptions As NameValueMap, ByRef oDataMedium As DataMedium)
oPath = ThisDoc.Path
oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
End Sub
Solved! Go to Solution.
Link copied