AddIn: display the button-icon (Visual Studio 2015/ C#)

AddIn: display the button-icon (Visual Studio 2015/ C#)

Anonymous
Not applicable
1,058 Views
1 Reply
Message 1 of 2

AddIn: display the button-icon (Visual Studio 2015/ C#)

Anonymous
Not applicable

Hello,

I'm having problems to convert my icon (ico) to the correct format. I already created the following button:

 

            Ribbons ribbons = m_inventorApplication.UserInterfaceManager.Ribbons;
            Ribbon partRibbon = m_inventorApplication.UserInterfaceManager.Ribbons[2]; //Part
            // add new panel
            RibbonTab myTab = partRibbon.RibbonTabs.Add("my Tab", "myTab", m_clientId);
            // add new tab
            RibbonPanel myPanel = myTab.RibbonPanels.Add("my Panel", "myPanel", m_clientId);

            // icons
            Icon bigIcon = InvAddIn.Properties.Resources.big;
            Icon smallIcon = InvAddIn.Properties.Resources.small;

            //HOW TO CONVERT ICON TO PICTURE?

            // button definition
            ControlDefinitions controlDefinitions = m_inventorApplication.CommandManager.ControlDefinitions;
            ButtonDefinition myButtonDef = controlDefinitions.AddButtonDefinition("my Button", "myButton", CommandTypesEnum.kNonShapeEditCmdType, m_clientId, StandardIcon: smallPicture, LargeIcon: largePicture);

            // add the button to the new panel
            myPanel.CommandControls.AddButton(myButtonDef);

 

 

I took a look at the "SimpleAddin" (DeveloperTools\Samples\VCSharp.NET\AddIns\SimpleAddIn). Its not working for me:

image.png

Regards

Patrick

0 Likes
1,059 Views
1 Reply
Reply (1)
Message 2 of 2

YuhanZhang
Autodesk
Autodesk

Hi Patrick,

 

In below post there is another way to convert Icon to IPictureDisp, can you try it there to see if it works:

 

http://adndevblog.typepad.com/manufacturing/2012/06/how-to-convert-iconbitmap-to-ipicturedisp-withou...

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes