C# Getthumbnail2 Method problem in my PDM Add-in

299 views Asked by At

I'm coding an add-in for solidworks pdm. I use epdm interop library. But i got some issues to Getthumbnail2 Method. I use in this way:

IEdmFile5 file5 = vault.GetFileFromPath(filePath, out IEdmFolder5 folder5);
            var version = file5.CurrentVersion;
            IEdmFile15 file15 = (IEdmFile15)file5;
            var obj = file15.GetThumbnail2(version);

            Image imgPreview = PictureDispC.PictureDispConverter.Convert(obj);
            imgPreview.Save(GetTempPath() + parcaadi + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            imgPreview.Dispose();

I encountered this error code:

System.Runtime.InteropServices.COMException
  HResult=0x8004040B
  İleti=HRESULT özel durum döndürdü: 0x8004040B

At This line;

var obj = file15.GetThumbnail2(version);

Method decleration: https://help.solidworks.com/2019/english/api/epdmapi/epdm.interop.epdm~epdm.interop.epdm.iedmfile15~getthumbnail2.html

Example usage:https://help.solidworks.com/2019/english/api/epdmapi/Get_File_Thumbnail_by_Version_Example_CSharp.htm

1

There are 1 answers

0
Ufukt On BEST ANSWER

The only problem is that it has to be logged in to work.

IEdmVault5 vault5 = new EdmVault5();
var vaultName = vault5.GetVaultNameFromPath(filePath);
vault5.Login("admin", "", vaultName);
IEdmFile5 file5 = vault5.GetFileFromPath(filePath, out IEdmFolder5 folder5);