hiermit speichere das Thumbnail. Nur das Problem, manchmal klappt es manchmal nicht. Das Versuchsobjekt ist immer das gleiche. Es wird auch keine Fehlermeldung ausgegeben. Jemand eine Idee?
Code: Dim othumbNail As IPictureDisp = refDoc.Thumbnail Dim picDispThumb As stdole.IPictureDisp = othumbNail Dim imageThumb As Image = AxHostConverter.PictureDispToImage(picDispThumb) imageThumb.Save("C:\Temp\TempThumb.bmp")
Public Shared Function PictureDispToImage(pictureDisp As stdole.IPictureDisp) As Image Return GetPictureFromIPicture(pictureDisp) End Function
Public Shared Function ImageToPictureDisp(image As Image) As stdole.IPictureDisp Return DirectCast(GetIPictureDispFromPicture(image), stdole.IPictureDisp) End Function
erstellt am: 18. Okt. 2021 14:15 <-- editieren / zitieren --> Unities abgeben: Nur für xerxses
War nur reiner Zufall, dass ich da gerade vorbeigeschaut habe.
Ich denke die "InventorThumbnailView.dll" brauchst du gar nicht. Das Problem hat eher mit dem negativen Hander zu tun. Das ist der entsprechende Code von Brian der das Problem löst:
Code:' Code in the button Click event. With OpenFileDialog1 .Filter = "Inventor Files (*.ipt;*.iam;*.idw)|*.ipt;*.iam;*.idw" If .ShowDialog() = System.Windows.Forms.DialogResult.OK Then ' Create an instance of the thumbnail viewer component. Dim thumbviewer As New _ InventorThumbnailViewLib.ThumbnailProvider
' Use the component to get the thumbnail. Dim pic As stdole.IPictureDisp = Nothing Dim handle As Long = 0
' Use workaround to make sure handle is a positive number. ' Otherwise the call to PictureDispToImage will fail. Do pic = thumbviewer.GetThumbnail(.FileName) handle = pic.Handle Loop While handle < 0
' Convert the IPictureDisp into an Image to ' display it in the picture box. Dim img As Image = AxHostConverter.PictureDispToImage(pic) PictureBox1.Image = img End If End With
Bei mir sieht in VB.Net so aus:
Code: Dim thumb As stdole.IPictureDisp = Nothing Dim hnd As Integer = 0 Dim i As Integer = 0 Do thumb = activeDoc.Thumbnail hnd = thumb.Handle i += 1 Debug.WriteLine("GetThumb: Type: " & thumb.Type.ToString) Debug.WriteLine("GetThumb: Handle: " & thumb.Handle.ToString) Loop While hnd < 0 Or i > 99