Icon for add-in button in 64bits environment

Icon for add-in button in 64bits environment

mr_ensing
Advocate Advocate
1,064 Views
3 Replies
Message 1 of 4

Icon for add-in button in 64bits environment

mr_ensing
Advocate
Advocate

So, i'm hacking away at my first add-in. Read several papers and got it to work. Now i'd like to add an icon to the button.

I soon understood that i need to convert from system.drawing.image to Inventor.IPictureDisp.

The problem with that seems that everything is 64 bits nowadays. 

 

' Convert the Image to a Picture.
Dim picture As stdole.IPictureDisp
picture = Microsoft.VisualBasic.Compatibility.VB6.ImageToIPictureDisp( _
My.Resources.Smiley)

 

Example code like above (out of this paper) just doesn't work, due to it being obsolete and supported within 32 bit processes only.

 

Next up is Philippe Leefsma's utility class. To use this, i need to reference stdole.dll. If i do, it works, but i get a warning during build:

 

warning BC40059: A reference was created to embedded interop assembly 'stdole' because of an indirect reference to that assembly from assembly 'Autodesk.Inventor.Interop'. Consider changing the 'Embed Interop Types' property on either assembly.

 

If i don't refence stdole.dll, Visual Studio suggests i change stdole.IPictureDisp (in Philippe Leefsma's class) to IPictureDisp.

 stdole.png

 

That works for a bitmap as well as for an icon (.ico).

Next up is trying to get it in the ribbon (for now it is a classic toolbar with one button floating over my Inventor window).

If there is a question, it is this: does this need to be so complicated? Might there be an easier conversion i haven't found yet?

0 Likes
1,065 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I came acros this, Visual Studio doesn't like the VB6 method - I came across this method instead, which works OK for me:

 

Dim mIPictureDisp1 As IPictureDisp = PictureDispConverter.ToIPictureDisp(My.Resources.Tools)

 

Tom

0 Likes
Message 3 of 4

mr_ensing
Advocate
Advocate

If you use PictureDispConverter, then i gues you are using  the utility class by Philippe Leefsma i mentioned?

0 Likes
Message 4 of 4

Anonymous
Not applicable

Ah sorry, yes I am.
I remember that I spent quite a bit of time looking for a simpler solution, but I didn't find anything and ended up using Philippe's class.

0 Likes