How to save on the disk the thumbnail image of an Inventor file?

By Philippe Leefsma

Saving the thumbnail image of an Inventor document as a file of your disk might be a bit tricky.

Here is how to do it in C#. The code will save as a .jpg but saving to other formats will be very easy, by simply changing the filename and the ImageFormat enum:

[DllImport(

    "oleaut32.dll",

    EntryPoint = "OleSavePictureFile",

    ExactSpelling = true,

    PreserveSig = false,

    SetLastError = true)]

public static extern void OleSavePictureFile(

    stdole.IPictureDisp Picture,

    [MarshalAs(UnmanagedType.BStr)] string filename);

 

void SaveThumbnail(Document doc)

{

    stdole.IPictureDisp pic = doc.Thumbnail;

 

    string filename = System.IO.Path.GetTempFileName();

 

    //Temp file is a .wmf

    OleSavePictureFile(pic, filename);

 

    Image img = Image.FromFile(filename, true);

 

    img.Save(

        @"C:\Temp\thumbnail.jpg",

        System.Drawing.Imaging.ImageFormat.Jpeg);

 

    System.IO.File.Delete(filename);

}

<

p style=”line-height: normal;margin: 0in 0in 0pt” class=”MsoNormal”> 


Comments

One response to “How to save on the disk the thumbnail image of an Inventor file?”

  1. Does it work with Inventor 2013??
    But I do not know about programming
    how do I apply this in inventor?
    I am mechanical designer
    I need thumbnail images
    please help me

Leave a Reply to PaoloCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading