Hi @michele_cavallerinTTNQ9. Although I do sometimes import STEP files, I rarely do so by code, so I did not have a previously created code example to post for the import method, but I do have a code example you can use for getting the 'import options' used by that method. This will write their names, value types, and current (or default) values out to the iLogic Logger window when ran. It can then be copied out to a text file, if necessary, or the code example could be modified to write the results directly to a text file instead of the iLogic Logger window.
I will post the code example below, so you can try it out. And I will attach an example result from the Logger window as a text file, because its contents are pretty long (from Inventor 2024).
When using the Inventor.TranslatorAddIn object's methods, you can get different results depending on the Type of document you are interacting with (part, assembly, drawing [idw or dwg], presentation), but the names and value types of the 'options' should not change. Different options may be available though, and they may have different 'default' values. For example importing a simple STEP file that was originally a simple part into an Inventor Part has one set of options, while importing a large STEP file that was originally an assembly into an Inventor Assembly will have have additional options that are not relevant for a simple part.
Sub Main
Dim oTranslator As Inventor.TranslatorAddIn = Nothing
For Each oAppAddin As Inventor.ApplicationAddIn In ThisApplication.ApplicationAddIns
'<<< MODIFY DISPLAYNAME AS NEEDED HERE >>>
If oAppAddin.DisplayName = "Translator: STEP" Then oTranslator = oAppAddin
Next
If oTranslator Is Nothing Then Exit Sub 'it was not found
'specify the full path & file name of the file you want to Open or Import.
'<<< MODIFY FULL FILE NAME AS NEEDED HERE - OR USE FILE BROWSER >>>
Dim sFileToImport As String = "C:\Temp\My STEP file.stp"
LogTranslatorOptions(oTranslator, sFileToImport)
End Sub
Sub LogTranslatorOptions(oTransAddIn As Inventor.TranslatorAddIn, sFileName As String)
Dim oTO As Inventor.TransientObjects = ThisApplication.TransientObjects
Dim oDataMedium As Inventor.DataMedium = oTO.CreateDataMedium()
oDataMedium.FileName = sFileName
Dim oContext As Inventor.TranslationContext = oTO.CreateTranslationContext()
oContext.Type = Inventor.IOMechanismEnum.kUnspecifiedIOMechanism
Dim oOptions As Inventor.NameValueMap = oTO.CreateNameValueMap()
oTransAddIn.ShowOpenOptions(oDataMedium, oContext, oOptions)
If oTransAddIn.HasOpenOptions(oDataMedium, oContext, oOptions) Then
'use this next line to visibly show the Open Options dialog
'oTransAddIn.ShowOpenOptions(oDataMedium, oContext, oOptions)
Dim i As Integer = 1
For Each oPair In oOptions
Dim sName As String = oOptions.Name(i)
Dim oValue As Object = oOptions.Value(sName)
Logger.Info(vbCrLf & _
"Option Name = " & sName & vbCrLf & _
"Option Value TypeName = " & TypeName(oValue) & vbCrLf & _
"Option Value = " & oValue.ToString() & VbCrLf)
i += 1
Next 'oPair
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) 👍.
Wesley Crihfield

(Not an Autodesk Employee)