Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Createimage giving error while saveasbitmap works

19 REPLIES 19
Reply
Message 1 of 20
Anonymous
1144 Views, 19 Replies

Createimage giving error while saveasbitmap works

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
19 REPLIES 19
Message 2 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 3 of 20
Anonymous
in reply to: Anonymous

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
Message 4 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 5 of 20
Anonymous
in reply to: Anonymous

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

Message 6 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 7 of 20
Anonymous
in reply to: Anonymous

IPictureDisp? Like this?

Document doc = doc.PropertySets["Inventor Summary Information"] ["Thumbnail"] ;
stdole.IPictureDisp pic = val as stdole.IPictureDisp;
Message 8 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 9 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 10 of 20
Anonymous
in reply to: Anonymous

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#
Message 11 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 12 of 20

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 !

Message 13 of 20
Anonymous
in reply to: Anonymous

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?
Message 14 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 15 of 20
Anonymous
in reply to: Anonymous

I don't know how to do that
Message 16 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 17 of 20
Anonymous
in reply to: Anonymous

Thank you very much
Message 18 of 20
bradeneuropeArthur
in reply to: Anonymous

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 !

Message 19 of 20

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 !

Message 20 of 20
Anonymous
in reply to: bradeneuropeArthur

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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report