Exporting IGS and STEP

Exporting IGS and STEP

taher.basha
Enthusiast Enthusiast
523 Views
5 Replies
Message 1 of 6

Exporting IGS and STEP

taher.basha
Enthusiast
Enthusiast

Hi,

 

I am trying to export a model to IGS and STEP. when the model is exported, there is a dialogue box immediately appreas saying that "unable to open the file" as shown in pic down.

 

Is Inventor trying to open the exported file immediately? if yes. then how to suppress the opening of igs and step

 

Public Sub ExportToIGES()
    ' Get the IGES translator Add-In.
    Dim oIGESTranslator As TranslatorAddIn
    Set oIGESTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F44-0C01-11D5-8E83-0010B541CD80}")

    If oIGESTranslator Is Nothing Then
        MsgBox "Could not access IGES translator."
        Exit Sub
    End If

    Dim oContext As TranslationContext
    Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
    If oIGESTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
        ' Set geometry type for wireframe.
        ' 0 = Surfaces, 1 = Solids, 2 = Wireframe
        oOptions.Value("GeometryType") = 1

        ' To set other translator values:
        ' oOptions.Value("SolidFaceType") = n
        ' 0 = NURBS, 1 = Analytic

        ' oOptions.Value("SurfaceType") = n
        ' 0 = 143(Bounded), 1 = 144(Trimmed)

        oContext.Type = kFileBrowseIOMechanism

        Dim oData As DataMedium
        Set oData = ThisApplication.TransientObjects.CreateDataMedium
        oData.FileName = "C:\Temptest.igs"

        Call oIGESTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
    End If
End Sub

Data exchange.jpeg

0 Likes
524 Views
5 Replies
Replies (5)
Message 2 of 6

JelteDeJong
Mentor
Mentor

I translated your code to vb.net/ilogic code and it works without any issues. (Plz, be aware that VBA is obsolete. Have a look at this blog post "Is VBA in Inventor obsolete?".) it looks like this. I found 1 problem that could be the problem. The file name in your example code is in the c root. I expect that you wanted to save your file in the temp folder but made a typo.

' Get the IGES translator Add-In.
Dim oIGESTranslator As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{90AF7F44-0C01-11D5-8E83-0010B541CD80}")

If oIGESTranslator Is Nothing Then
    MsgBox("Could not access IGES translator.")
    Exit Sub
End If

Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
If oIGESTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
    ' Set geometry type for wireframe.
    ' 0 = Surfaces, 1 = Solids, 2 = Wireframe
    oOptions.Value("GeometryType") = 1

    ' To set other translator values:
    ' oOptions.Value("SolidFaceType") = n
    ' 0 = NURBS, 1 = Analytic

    ' oOptions.Value("SurfaceType") = n
    ' 0 = 143(Bounded), 1 = 144(Trimmed)
    oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism

    Dim oData As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
    oData.FileName = "C:\Temp\test.igs"

    Call oIGESTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 6

taher.basha
Enthusiast
Enthusiast
I changed the saving address, and the saving address changes all time with change in model.

anything has to do with this line of code "oIGESTranslator.HasOpenOptions"
which can stop opening the model immediately
0 Likes
Message 4 of 6

vpeuvion
Advocate
Advocate

Hi,

The problem is probably that you are trying to write to the root of C: and you do not have permission.

Vincent.

0 Likes
Message 5 of 6

JelteDeJong
Mentor
Mentor

You could try to check your file names before you try to export. you could use a method like this:

	Public Sub Main()

        MsgBox(hasWriteAccessToFolder("C:\Temp\test.igs"))

    End Sub

    Private Function hasWriteAccessToFolder(folderPath) As Boolean
        Try
            Dim ds As System.Security.AccessControl.DirectorySecurity = System.IO.Directory.GetAccessControl(folderPath)
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 6 of 6

taher.basha
Enthusiast
Enthusiast
For sure! I will use this solution
0 Likes