Get Inventor Thumbnail image from webservice

Get Inventor Thumbnail image from webservice

rui.frazao.oliveira
Contributor Contributor
725 Views
7 Replies
Message 1 of 8

Get Inventor Thumbnail image from webservice

rui.frazao.oliveira
Contributor
Contributor

Hi,

 

I am trying to get Inventor Thumbnail image from files in a server using a webservice.

 

I have found in web the following article:

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

 

And the code in this article works perfect when I tested it from a local Windows Application. I developed an sample in C# similar to the ones in VB and VB.NET available in article and works perfect. Here is my code:

 

       private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "Inventor Files (*.iam; *.idw; *.ide; *.ipt; *.ipn)|*.iam;*.idw;*.ide;*.ipt;*.ipn|Assembly Fiels (*.iam)|*.iam|Drawing Files (*.idw)|*.idw|iFeature Files (*.ide)|*.ide|Part Files (*.ipt)|*.ipt|Presentation Files (*.ipn)|*.ipn|All Files (*.*)|*.*";
            dlg.ShowDialog();
            string ls_sourceFileName = dlg.FileName;

            if (icl_thumbnailProvider == null)
                icl_thumbnailProvider = new InventorThumbnailViewLib.ThumbnailProvider();
            if (icl_thumbnailProvider == null)
                return;

            int lcl_hCode = icl_thumbnailProvider.GetHashCode();
            stdole.IPictureDisp lcl_pictureThumbnail = icl_thumbnailProvider.GetThumbnail(ls_sourceFileName);

            Image lcl_image = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureDispToImage(lcl_pictureThumbnail);

            pictureBox1.Image = lcl_image;
        }

The problem starts when I try to call the fuction GetThumbnail directly from an Webservice, that gives me the error "Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))". Here is my code:

 

                    InventorThumbnailViewLib.ThumbnailProvider icl_thumbnailProvider = new InventorThumbnailViewLib.ThumbnailProvider();
                    if (icl_thumbnailProvider == null)
                        return null;

                    stdole.IPictureDisp lcl_pictureThumbnail = icl_thumbnailProvider.GetThumbnail(ls_sourceFileName);
                   
                    Image lcl_image = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureDispToImage(lcl_pictureThumbnail);
                    MemoryStream ms = new MemoryStream();
                    lcl_image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                    return  ms.ToArray();

and the error appears exactly in line:

stdole.IPictureDisp lcl_pictureThumbnail = icl_thumbnailProvider.GetThumbnail(ls_sourceFileName);

What could be? There are some limitation of use this library from a webservice?

 

Thanks & Regards,

Rui

 

 

 

0 Likes
726 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

Hello @rui.frazao.oliveira

 

When you call the Webservice where is your Inventor file? What is the content of the variable ls_sourceFileName?

 

Usually you would have to send the Inventor file to the webservice, have that webservice store the file on the server side, get the thumbnail and then delete the uploaded file again, so you would need the webservice to have access to a server folder with read and write access.

 

Regards,

Jens Bejer Pedersen

Developer, Symetri A/S

www.symetri.com

0 Likes
Message 3 of 8

rui.frazao.oliveira
Contributor
Contributor

Hi Jens

 

The variable ls_sourceFileName have the full path to the file in server side.

 

I have all Inventor files in server side, and I have an application that connect with server by webservices, this application will browse all files in a server folder and show the thumbnail for each file.

 

All this these things are correct, and my application already are browsing well files in server. The only problem is when I want show the Inventor thumbnail using the code above.

 

Thanks & regards,

Rui

0 Likes
Message 4 of 8

Anonymous
Not applicable

Hello @rui.frazao.oliveira

 

Just to be certain, You are sure that the process that runs the webservice (usually this is an IIS process) has the proper settings for accessing the files on the server?

 

Are you also certain that the thumbnail extraction component is properly registered for that process?

 

Often the IIS runs webservice processes with limited rights both regarding the file system and the registry.

 

Unfortunately I'm not really able to assist with settings up IIS for these things if this should be the problem.

 

Regards,

Jens Bejer Pedersen

Developer, Symetri A/S

www.symetri.com

0 Likes
Message 5 of 8

rui.frazao.oliveira
Contributor
Contributor

Hi Jens,

 

Yes, have the correct setting to access files, I can browse them using the same webservice.

 

Yes, thumbnail extraction component is correctly registered. I can run my windows/form sample directly in server (using the same component) and works.

 

Thanks & Regards,

Rui

0 Likes
Message 6 of 8

Anonymous
Not applicable

Hello @rui.frazao.oliveira

 

Then I would suggest to pull out the big hammer and try to debug the webservice as it runs on the server.

0 Likes
Message 7 of 8

rui.frazao.oliveira
Contributor
Contributor

Jens,

I already did that too and everything goes well until goes outside of line:

 

 

stdole.IPictureDisp lcl_pictureThumbnail = icl_thumbnailProvider.GetThumbnail(ls_sourceFileName);

 

 

In debug I can go inside of GetThumbnail function (inside of thumbnail extraction component) too and goes well inside without any error. The error only appears after debug comes again from inside of the GetThumbnail to the webservice function where I call the GetThumbnail function.

 

Here is my code in webservices:

 

                    InventorThumbnailViewLib.ThumbnailProvider icl_thumbnailProvider = new InventorThumbnailViewLib.ThumbnailProvider();
                    if (icl_thumbnailProvider == null)
                        return null;

                    stdole.IPictureDisp lcl_pictureThumbnail = icl_thumbnailProvider.GetThumbnail(ls_sourceFileName);
                   
                    Image lcl_image = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureDispToImage(lcl_pictureThumbnail);
                    MemoryStream ms = new MemoryStream();
                    lcl_image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                    return  ms.ToArray();

 

In debug I go until the line:

stdole.IPictureDisp lcl_pictureThumbnail = icl_thumbnailProvider.GetThumbnail(ls_sourceFileName);

And go inside of the GetThumbnail function (inside of thumbnail extraction component) until the end without any error, and when debug returns to the webservice code, before the next line, gives the error.

 

Rui

0 Likes
Message 8 of 8

rui.frazao.oliveira
Contributor
Contributor

If I comment in function GetIPictureDispFromClipdata the line

 

HRESULT hr = OleCreatePictureIndirect(&pdesc, IID_IPictureDisp, TRUE, (LPVOID*)& pPicDisp);  

 

 

The error disappears. Of course it is not solutions because returns null in this case.

0 Likes