Inventor Apprentice 2015 not reading files.

Inventor Apprentice 2015 not reading files.

Anonymous
Not applicable
625 Views
1 Reply
Message 1 of 2

Inventor Apprentice 2015 not reading files.

Anonymous
Not applicable

I'm having some difficulty figuring out why ApprenticeServer will not read Inventor files migrated from 2013 to 2015 in my API code....

 

The code below reads a 2013 file just fine, but errors out on "doc = apprentice.Open(strFile)" with a migrated 2015 file.

 

The help file for the 2015 API looks the same as 2013 on this subject. The image below shows the error that is catched. Help!!!

 

Using Visual Studio 2012 and VB.NET.

 

Error.jpg

 

    Private Sub ShowThumbnail(ByVal strFile As String)

        If Not System.IO.File.Exists(strFile) Then

            MsgBox("File does not exist.")
            Exit Sub

        End If

        ' Create an instance of Apprentice.
        Dim apprentice As New ApprenticeServerComponent

        ' Open a document.
        Dim doc As ApprenticeServerDocument
        Try
            doc = apprentice.Open(strFile)
            'doc = apprentice.OpenWithOptions(strFile, Nothing)
        Catch ex As Exception

            MsgBox(ex.ToString())
            doc.Close()

            Exit Sub
        End Try

        ' Get the thumbnail image.
        Dim thumbnail As stdole.IPictureDisp
        thumbnail = doc.Thumbnail

        ' Convert the IPictureDisp object to an Image.
        Dim img As System.Drawing.Image = AxHostConverter.PictureDispToImage(thumbnail)

        With imgLogo
            .ImageSource = ConvertDrawingToImagesource(img)
            .Stretch = Stretch.Fill
        End With

        Label_Status_Comment.Content = "Selected Template: " & GetPhantomiPropertyByFileName(doc, "Keywords", _summaryProp)

        SetGeneralAssemblyFields(GetPhantomiPropertyByFileName(doc, "FDCode", _customProp))

        doc.Close()

    End Sub

 

 

0 Likes
Accepted solutions (1)
626 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

I found the solution to the problem in this article... I added a Do While loop to make sure the thumbnail handle was not a negative number...

http://modthemachine.typepad.com/my_weblog/2012/05/thumbnail-viewer-component-on-a-64-bit-system.htm...