- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
How do i save the thumbnail with ilogic in a part-file?
I have written this ilogic code, but it is not working - Can somebody help me?
Imports System.Windows.Forms
Imports System.Drawing
AddReference "System.Drawing"
AddReference "stdole"
Sub Main
' Get the active document (must be a PartDocument)
Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
If oPartDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("Please open a part document.")
Exit Sub
End If
' Get the thumbnail from iProperties
Dim oThumbnail As stdole.IPictureDisp = oPartDoc.PropertySets.Item("Inventor Summary Information").Item("Thumbnail").Value
' Convert the IPictureDisp to a .NET Bitmap object using the converter class
Dim oPicture As System.Drawing.Image = IPictureDispConverter.PictureDispToImage(oThumbnail)
If oPicture IsNot Nothing Then
' Use the oPicture object, for example:
MsgBox("Thumbnail converted successfully!")
oPicture.Save("C:\TEMP\Thumbnail.jpg")
Else
MsgBox("Failed to convert thumbnail.")
End If
End Sub
' Custom class that exposes the GetPictureFromIPictureDisp method from AxHost
Public NotInheritable Class IPictureDispConverter : Inherits AxHost
Private Sub New()
MyBase.New("")
End Sub
' Function to convert IPictureDisp to Image
Public Shared Function PictureDispToImage(oThumbnail As stdole.IPictureDisp) As Image
Try
' Use the protected method from AxHost to convert IPictureDisp to Image
Return GetPictureFromIPictureDisp(oThumbnail)
Catch ex As Exception
myparam = InputBox("Error converting: ", "Conversion Error", ex.Message)
Return Nothing
End Try
End Function
End Class
Solved! Go to Solution.