Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

code for thumbnails fails in inventor 2014

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
602 Views, 2 Replies

code for thumbnails fails in inventor 2014

Hello,

 

I have a code to shows a thumbnail of inventor drawings and it works in inventor 2012 but gives an error in inventor 2014 (trail)

 

It shows a thumbnail of inventor drawings and I used the examples on this website:

http://modthemachine.typepad.com/my_weblog/2010/06/accessing-thumbnail-images.html

 

The filelocation of the document is correct (i checked the error message with catch)

 

            Try

                Dim doc As Document = oApp.Documents.Open(FileDir & "\" & DisplayItem & ".idw", False)

                Dim thumbnail As stdole.IPictureDisp = doc.Thumbnail

                Dim img As Image = Compatibility.VB6.IPictureDispToImage(thumbnail)

                Me.PictureBox1.Image = img

            Catch

                MsgBox(FileDir & "\" & DisplayItem & ".idw")

            End Try

 

Is there a change in the way stdole.IPictureDisp or Compatibility.VB6.IPictureDispToImage(thumbnail) works?

Perhaps a change in how inventor handles thumbnails?

 

Thx in advance,

 

Arnold

2 REPLIES 2
Message 2 of 3
xiaodong_liang
in reply to: Anonymous

Hi,

 

Since Compatibility.VB6 is obsolete, I'd recommend the AxHost. I tested with Inventor 2014, it works well.

 

Imports System.IO
Imports System.Windows.Forms
Imports System.Drawing

Public Class Form1

    Public invApp As Inventor.Application


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim doc As Inventor.Document = invApp.Documents.Open("c:\xx.idw", False)
        Dim oObj As Object = doc.Thumbnail
        PictureBox1.Image = AxHostConverter.PictureDispToImage(doc.Thumbnail)
    End Sub
End Class

''from http://blogs.msdn.com/b/andreww/archive/2007/07/30/converting-between-ipicturedisp-and-system-drawin...

Friend Class AxHostConverter
    Inherits AxHost
    Private Sub New()
        MyBase.New("")
    End Sub


    Public Shared Function ImageToPictureDisp(image As Image) As stdole.IPictureDisp
        Return DirectCast(GetIPictureDispFromPicture(image), stdole.IPictureDisp)
    End Function


    Public Shared Function PictureDispToImage(pictureDisp As stdole.IPictureDisp) As Image
        Return GetPictureFromIPicture(pictureDisp)
    End Function
End Class

 

Message 3 of 3
matt_jlt
in reply to: xiaodong_liang

I'm using the exact code "Axhost" but am getting an error "Generic error occurred in GDI+" when diplaying multiple thumbnails.

 

The list of events are as follows:

 

I have a single form, with a list view of all drawings. I load the thumbnail of each when it's selected. It works for the first one but usually throws the error i mentioned above for any after that?

 

Anyone else getting this problem?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report