Createimage giving error while saveasbitmap works

Anonymous

Createimage giving error while saveasbitmap works

Anonymous
Not applicable
Hello.
I'm trying to create an app and I am using inventor 2017 window hidden, so to show the view of what the user is working on I find the methods "createimage" and "saveasbitmap", the best to use is createimage because it doesn't stores the image in a file, making it more eficiant, but i cann't get it to work.
I tried:

Camera cam = _inv.ActiveView.Camera;
cam.CreateImage(500,500);

But this creates an exception when running (catastrophic failure (exception from HRESULT: 0x800FFFF (E_UNEXPECTED)))
When I trie with saveasbitmap it works:
Camera cam = inv.ActiveView.Camera;
String file = "C:\\Users\\User\\Desktop\\test.jpg" ;
cam.SaveAaBitmap(file, 500,500);
Bitmap img = new Bitmap(file) ;
pictureBox1.Image = (Image)img;


Am I doing something wrong here? I have tried to find the answer by myself, but without success.
If there is another method of doing what I want using Inventor window as hide I also would like to hear
0 Likes
Reply
1,144 Views
19 Replies
Replies (19)

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Could you please try to explain a little more what you are trying to achieve.

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable
I'm trying to show the view from inventor in another interface, but I can seem to find a way to use the createimage method from inventor api, because it keeps getting a (catastrophic failure (exception from HRESULT: 0x800FFFF (E_UNEXPECTED))). Because of that I'm using the SaveAsBitmap method to store a view image and the show it to the user, this second option works, but it isn't the best way to do it because it most do much more tasks. So I would like to know how to use the createimage method insted of the saveasbitmap. The code I use is in the first comment.

Thanks and best regards
0 Likes

bradeneuropeArthur
Mentor
Mentor
use the thumbnail property.....

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable
But does the thumbnail property get the view image of and assembly?
If yes, how can I use it in C#?

0 Likes

bradeneuropeArthur
Mentor
Mentor
Yes.

Convert it to I picture

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable
IPictureDisp? Like this?

Document doc = doc.PropertySets["Inventor Summary Information"] ["Thumbnail"] ;
stdole.IPictureDisp pic = val as stdole.IPictureDisp;
0 Likes

bradeneuropeArthur
Mentor
Mentor
Like that...

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

bradeneuropeArthur
Mentor
Mentor
modthemachine.typepad.com/my_weblog/2010/06/accessing-thumbnail-images.html

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable
That's the code I'm trying to follow, but it's in VBA and I am working with C# and the Compatibility.VB6.IPictureDispToImage(thumbnail) doesn't seem to exist in C#
0 Likes

bradeneuropeArthur
Mentor
Mentor
You can use this object also from inventor. I mean IPictureDisp""

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

bradeneuropeArthur
Mentor
Mentor
Module mdlViewtumbnail

Friend Sub Viewtumbnail()

' Get the Summary Information property set.
Dim summaryInfo As PropertySet
summaryInfo = UfrmStart.oInvApp.ActiveDocument.PropertySets.Item("Inventor Summary Information")

' Get the thumbnail property.
Dim thumbProp As Inventor.Property
thumbProp = summaryInfo.Item("Thumbnail")

' Get the thumbnail image.
Dim thumbnail As stdole.IPictureDisp
thumbnail = thumbProp.Value

' Convert the IPictureDisp object to an Image.
'Dim img As Image = Compatibility.VB6.IPictureDispToImage(thumbnail)

' Display the image in the picture box.
' UfrmStart.PictureBox1.Image = img



End Sub
End Module

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable
Ok, I can now get the thumbnail and convert the IPictureDisp to Image and display it in a picturebox, it doesn't give any any error, but it also doesn't show any image because the thumbnail handle is null, why is this appening?
0 Likes

bradeneuropeArthur
Mentor
Mentor
Maybe you create no thumbnail with the save....
Go to document settings an change to create thumbnail...

if you need assistance please let me know.

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable
I don't know how to do that
0 Likes

bradeneuropeArthur
Mentor
Mentor
I will take a look this evening... Ok..

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable
Thank you very much
0 Likes

bradeneuropeArthur
Mentor
Mentor

The following works for me:

            Dim apprentice As New ApprenticeServerComponent

            ' Open a document.  
            Dim doc As ApprenticeServerDocument
doc = apprentice.Open("C:\Vault\Projects\Part1.ipt")'YOUR FILE FULL NAME HERE ' Get the thumbnail image. Dim thumbnail As stdole.IPictureDisp thumbnail = doc.Thumbnail ' Convert the IPictureDisp object to an Image. Dim img As Image = Compatibility.VB6.IPictureDispToImage(thumbnail) ' Display the image in the picture box. PICTUREBOX OF YOUR FORM PictureBox1.Image = img

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

bradeneuropeArthur
Mentor
Mentor
Also this will help you:

C:\Users\Public\Documents\Autodesk\Inventor 20##\SDK\DeveloperTools\Tools\ThumbnailView\ThumbnailView Samples\VB.Net

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

0 Likes

Anonymous
Not applicable

Wow, so much text and „advice“ for a simple question: „Why the function CreateImage doesn’t work“. It doesn’t work here neither and “solution” over thumbnail is NO SOLUTION. So anyone from Autodesk here who can provide .NET example of the function or tell us why it doesn’t work the way it should?