
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to use the file name (minus the extension) to name an exported STEP file. I know the exporting function works, but I am having difficulty getting the file name to work. Note, in the code below, I am just trying to get the code to run without errors; oFileName = ThisDoc.FileName(False) flags an error "Run-time error '424': Object Required".
I don't know why this is the case, because I have been trying to adapt the code from the following post, where their's seems to work.
https://forums.autodesk.com/t5/inventor-customization/save-as-step-using-ilogic/td-p/7843312
Not sure if this is something with Inventor 2020 changing API structure/terminology causing the other code to be invalid.
Another note; Right now I have this running as an external rule so that every part can have access to it, as well as being available to all members of my team. Not sure if this changes how things need to be initialized.
Public Sub ExportToSTEP() ' Get the STEP translator Add-In. Dim oSTEPTranslator As TranslatorAddIn Set oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") oFileName = ThisDoc.FileName(False) 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 Dim oData As DataMedium Set oData = ThisApplication.TransientObjects.CreateDataMedium oData.FileName = "S:\Engineering\Step Files\temptest.stp" Call oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData) End If End Sub
Solved! Go to Solution.