Use a thumbnail in a custom windows form

Use a thumbnail in a custom windows form

wouter
Advocate Advocate
266 Views
3 Replies
Message 1 of 4

Use a thumbnail in a custom windows form

wouter
Advocate
Advocate

Hi all,

 

I recently installed Inventor 2025 and some pieces of code stopped working. I quess its because they changed to .NET 8.0, but i have no idea how to rewrite this part to work in Inventor 2025. I use the thumbnail in a custom windows form.

 

'set iproperty to use ISO view on save
docFile.SetThumbnailSaveOption _
(ThumbnailSaveOptionEnum.kActiveComponentIsoViewOnSave)
Dim thumb As Inventor.IPictureDisp
thumb = docFile.Thumbnail
Dim img As Drawing.Image
img = Compatibility.VB6.IPictureDispToImage(thumb)

 Any tips are welcome! Thanks in advance

Wouter Vrouwenvelder

0 Likes
267 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @wouter.  Take a look into this forum post:

https://forums.autodesk.com/t5/inventor-programming-ilogic/copy-thumbnails-from-files-in-directory-t... 

There have been several forum topics about obtaining the Thumbnail image from documents for various uses, and a 'newer' way to do this has been available since at least 2012, where I first saw it being used.  There are some good links in that post too that you should look into, for further reading.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

Duplicate

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

wouter
Advocate
Advocate

Hi Wesley,

 

Only just had time to look into this and thanks for the tip. 

This is the simplefied version of the code i'm using which works fine for me.

 

AddReference "Path of my form.dll"
AddReference "system.drawing.dll"
AddReference "stdole.dll"

Sub Main()
Dim docFile As Inventor.Document = ThisApplication.ActiveDocument
Dim img As Image = ShowDocThumbnailInForm(docFile)
Dim dialogResultOK As Boolean = False
Using inputForm As New Data_Form_2025.Form1
inputForm.img = img

'----Form laten zien------------------
Dim formResult As DialogResult = inputForm.ShowDialog()

If formResult = DialogResult.OK Then
dialogResultOK = True
End If
End Using

If Not dialogResultOK Then Exit Sub

iLogicVb.UpdateWhenDone = True
'-----Einde--------------
End Sub

Function ShowDocThumbnailInForm(docFile As Inventor.Document) As Image
If docFile Is Nothing Then Return Nothing

Dim oThumb As IPictureDisp
Do
oThumb = docFile.Thumbnail
Loop While oThumb.Handle < 0

Dim oAHConverter As New AxHostConverter
Return oAHConverter.GetImageFromIPictureDisp(oThumb)
End Function


Public Class AxHostConverter
Inherits AxHost
Public Sub New()
MyBase.New((New Guid).ToString)
End Sub
Public Function GetImageFromIPictureDisp(ByVal IPDisp As IPictureDisp) As Image
Return MyBase.GetPictureFromIPicture(IPDisp)
End Function
End Class

0 Likes