open STEP file options

open STEP file options

Anonymous
Not applicable
785 Views
5 Replies
Message 1 of 6

open STEP file options

Anonymous
Not applicable
Hi,

I want to open a STEP file as an IPT file. But, by default in the "options" tab, "Import multi-Lump solids as assembly" is set to true. This causes the file to be imported as an assembly(IAM) file. If it is set to false, the file is imported as a IPT file.

How do i set above option to false, so that i can import the file as IPT file, through APIs? Please reply to the above query at the earliest?

regards,

Vikas
0 Likes
786 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
You can do this using the Translator Add-in APIs. You can set the various
import options before importing. Here is a sample that sets the option you
need...

Public Sub ImportSTEP()
' Find the STEP translator Add-In.
Dim oSTEPTranslator As TranslatorAddIn
Dim i As Integer
For i = 1 To ThisApplication.ApplicationAddIns.Count
If ThisApplication.ApplicationAddIns.Item(i).ClassIdString =
"{90AF7F40-0C01-11D5-8E83-0010B541CD80}" Then
Set oSTEPTranslator = ThisApplication.ApplicationAddIns.Item(i)
Exit For
End If
Next

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
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

oDataMedium.FileName = "C:\temp\test.stp"

If oSTEPTranslator.HasOpenOptions(oDataMedium, oContext, oOptions) Then

If oOptions.Count > 0 Then
Dim j As Long
For j = 1 To oOptions.Count
Debug.Print " " & oOptions.Name(j) & " = " &
oOptions.Value(oOptions.Name(j))
Next
End If

oOptions.Value("EnableMultiLumpsAsAsm") = False

Dim oTarget As Object
Call oSTEPTranslator.Open(oDataMedium, oContext, oOptions, oTarget)
End If

End Sub

Here is the list of all options...

Assembly_Destination_Dir = C:\temp
bCEMBCk = True
CEGroupLevel = 1
CEGroupMapping = 1
CEGroupNameOpt = 0
CEGroupNameString =
CEPrefixCk = False
CEPrefixString = Prefix
DynamicUnloadingCk = False
EnableAdvancedHealing = False
EnableImportPoints = True
EnableImportSolids = True
EnableImportSurfs = True
EnableImportWires = True
EnableMultiLumpsAsAsm = True
EnableQualityCheck = False
EnableStitchPromote = True
Part_Destination_Dir = C:\temp

Sanjay-

wrote in message news:5550891@discussion.autodesk.com...
Hi,

I want to open a STEP file as an IPT file. But, by default in the "options"
tab, "Import multi-Lump solids as assembly" is set to true. This causes the
file to be imported as an assembly(IAM) file. If it is set to false, the
file is imported as a IPT file.

How do i set above option to false, so that i can import the file as IPT
file, through APIs? Please reply to the above query at the earliest?

regards,

Vikas
0 Likes
Message 3 of 6

Anonymous
Not applicable
Hi,

thanks for the prompt reply.
I tried using a portion of the program that you had given. I am opening a STEP file and saving it as a IPT file. But, at the following statement,

Call oSTEPTranslator.Open(oDataMedium, oContext, oOptions, oTarget)

I am getting an error quoting, "Method 'Open' of object '_IRxTranslatorAddIn' failed".

The following is the function that i am using,


Public Function pbcfncSTEPtoPART(strIptOutFolder As String, strPartName As String, strFilePath As String, oExcel As Object, i As Integer)
Debug.Print "Entering function pbcfncSTEPtoPART()"
' Find the STEP translator Add-In.
'Dim oSTEPTranslator As TranslatorAddIn
Dim oSTEPTranslator As Inventor.TranslatorAddIn
Dim g As Integer
For g = 1 To gobjInvApp.ApplicationAddIns.Count
If gobjInvApp.ApplicationAddIns.Item(g).ClassIdString = "{90AF7F40-0C01-11D5-8E83-0010B541CD80}" Then
Set oSTEPTranslator = gobjInvApp.ApplicationAddIns.Item(g)
Exit For
End If
Next

If oSTEPTranslator Is Nothing Then
MsgBox "Could not access STEP translator."
Exit Function
End If

Dim oContext As TranslationContext
Set oContext = gobjInvApp.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
Set oOptions = gobjInvApp.TransientObjects.CreateNameValueMap
Dim oDataMedium As DataMedium
Set oDataMedium = gobjInvApp.TransientObjects.CreateDataMedium

oDataMedium.fileName = strFilePath

If oSTEPTranslator.HasOpenOptions(oDataMedium, oContext, oOptions) Then

If oOptions.Count > 0 Then
Dim j As Long
For j = 1 To oOptions.Count
Debug.Print " " & oOptions.Name(j) & " = " & oOptions.Value(oOptions.Name(j))
Next
End If

oOptions.Value("EnableMultiLumpsAsAsm") = False

Dim oTarget As Object
Call oSTEPTranslator.Open(oDataMedium, oContext, oOptions, oTarget)
'Set odoc = gobjInvApp.Documents.OpenWithOptions(strFilePath, oOptions, True)
End If

Dim strStepFileName As String
Dim strStepFileName1 As String
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

strStepFileName = strIptOutFolder + "\" + strPartName + "x1" + ".ipt"
strStepFileName1 = strIptOutFolder + "\" + strPartName + ".ipt"

If objFSO.FileExists(strStepFileName) = True Then
Call objFSO.DeleteFile(strStepFileName)
End If

If objFSO.FileExists(strStepFileName1) = True Then
Call objFSO.DeleteFile(strStepFileName1)
End If

Dim objDocStep As Inventor.PartDocument

'Create ipt file
Set objDocStep = gobjInvApp.Documents.Item(strStepFileName1)

objDocStep.SaveAs strStepFileName, False

objDocStep.Close False
objFSO.MoveFile strStepFileName, strStepFileName1

oExcel.Columns("Q:Q").Select
oExcel.Selection.NumberFormat = "m/d/yyyy h:mm:ss"

oExcel.Cells(i, 17).Value = objFSO.GetFile(strStepFileName1).DateLastModified

Set objDocStep = Nothing
Set objFSO = Nothing

pbcfncSTEPtoPART = NO_ERR
Debug.Print "Exiting function pbcfncSTEPtoPART()"
Exit Function

ErrorHandler:
Set objDocStep = Nothing
Set objFSO = Nothing
Debug.Print "Exiting function pbcfncSTEPtoPART()"
Exit Function

End Function

Please let me know if you have any solution.
0 Likes
Message 4 of 6

Anonymous
Not applicable
I've modified the code that I posted previously. This should work. It was
missing the following line:

oContext.Type = kFileBrowseIOMechanism

Also, the Open method opens the Inventor document invisibly. I added a few
lines of code to add a view to the opened document.

Sanjay-

Public Sub ImportSTEP()
' Find the STEP translator Add-In.
Dim oSTEPTranslator As TranslatorAddIn
Dim i As Integer
For i = 1 To ThisApplication.ApplicationAddIns.Count
If ThisApplication.ApplicationAddIns.Item(i).ClassIdString =
"{90AF7F40-0C01-11D5-8E83-0010B541CD80}" Then
Set oSTEPTranslator = ThisApplication.ApplicationAddIns.Item(i)
Exit For
End If
Next

If oSTEPTranslator Is Nothing Then
MsgBox "Could not access STEP translator."
Exit Sub
End If

Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism

Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

oDataMedium.FileName = "C:\temp\test.stp"

If oSTEPTranslator.HasOpenOptions(oDataMedium, oContext, oOptions) Then

If oOptions.Count > 0 Then
Dim j As Long
For j = 1 To oOptions.Count
Debug.Print " " & oOptions.Name(j) & " = " &
oOptions.Value(oOptions.Name(j))
Next
End If

oOptions.Value("EnableMultiLumpsAsAsm") = False

Dim oTarget As Object
Call oSTEPTranslator.Open(oDataMedium, oContext, oOptions, oTarget)

Dim oDoc As Document
Set oDoc = oTarget
oDoc.Views.Add
End If

End Sub


wrote in message news:5553125@discussion.autodesk.com...
Hi,

thanks for the prompt reply.
I tried using a portion of the program that you had given. I am opening a
STEP file and saving it as a IPT file. But, at the following statement,

Call oSTEPTranslator.Open(oDataMedium, oContext, oOptions, oTarget)

I am getting an error quoting, "Method 'Open' of object
'_IRxTranslatorAddIn' failed".

The following is the function that i am using,
0 Likes
Message 5 of 6

jjstr8
Collaborator
Collaborator

EnableMultiLumpsAsAsm doesn't appear to be an option anymore.  Does anyone know what to set to import a STEP assembly to a single part?  I checked the Options before and after calling ShowOpenOptions with and without "Import Assembly as Single Part" being checked.  Nothing appeared to change in the options.  I haven't had any luck with CreateIFO, ImportAASPIndex, and CreateSurfIndex.

0 Likes
Message 6 of 6

jjstr8
Collaborator
Collaborator

It turns out I missed the ImportAASP option.  I'm not sure why they felt the need to abbreviate "As A Single Part" in the first place, and not make any reference to it in the help file.  I still don't know what IFO stands for.

 

I ended up using the following:

nameValueMap.Value["ImportAASP"] = true;
nameValueMap.Value["ImportAASPIndex"] = 0;
nameValueMap.Value["AutoStitchAndPromote"] = true;

 

0 Likes