Extracting thumbnail vb.net

Extracting thumbnail vb.net

Anonymous
Not applicable
1,042 Views
1 Reply
Message 1 of 2

Extracting thumbnail vb.net

Anonymous
Not applicable

Hi,

 

I found the following code to extract a thumbnail image from an inventor part.. However I get an error saying

 

Error 1 'Compatibility' is not declared. It may be inaccessible due to its protection level.

 

how do I fix this?

 

The code:

 

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

        ' Open a document.  
        Dim doc As ApprenticeServerDocument
        doc = apprentice.Open("C:\test.ipt")

        ' Get the Summary Information property set.  
        Dim summaryInfo As PropertySet
        summaryInfo = doc.PropertySets.Item( _
                                      "Inventor Summary Information")

        ' Get the thumbnail property.  
        Dim thumbProp As Inventor.Property
        thumbProp = summaryInfo.Item("Thumbnail")

        ' Get the thumbnail image.  
        Dim thumbnail As stdole.IPictureDisp
        thumbnail = thumbProp.Value

        ' Convert the IPictureDisp object to an Image.  
        Dim img As Image = Compatibility.VB6.IPictureDispToImage(thumbnail)

        ' Display the image in the picture box.  
        PictureBox1.Image = img

 The orriginal code was found at the following url...

 

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

0 Likes
1,043 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Are you using 64 bit Inventor?

If yes, I think that is why you're getting an error.

 

Copy and pasted from the link in your post.

 

Thumbnail as an iProperty
The thumbnail is stored as an iProperty within an Inventor document.  One way to access the thumbnail is as an iProperty.  The following VBA code accesses the thumbnail as an iProperty and writes it as a bmp file to disk.  (This code won’t work on a 64-bit Inventor because of the issues discussed in this post.)

 

0 Likes