Author Topic: Problem with IAcadToolbarItem.SetBitmap and 2017-PNG-Icons  (Read 1763 times)

0 Members and 1 Guest are viewing this topic.

MarioR

  • Newt
  • Posts: 65
Problem with IAcadToolbarItem.SetBitmap and 2017-PNG-Icons
« on: December 21, 2017, 11:04:32 AM »
Hello,

i change Icons on AutoCAD 2014 from ribbons an toolbars to display any stats.
Now i must change to AutoCAD 2017 with transparent PNG-files. Change the ribbon-icons are works fine, but when i change the ToolbarButtons crashed the function  IAcadToolbarItem.SetBitmap(...) with:

Code: [Select]
System.ArgumentException Source Autodesk AutoCAD Civil 3D 2017
Ungültiges Argument C:\Program Files\Autodesk\ApplicationPlugins\KSRO_ChangeOSNAP.bundle\Contents\CUI\KSRO_OSNAP_POINT_16_OFF.PNG in SetBitmap ==>>
   bei Autodesk.AutoCAD.Interop.IAcadToolbarItem.SetBitmaps(String SmallIconName, String LargeIconName)

What is the correct way on AutoCAD2017 to change ToolbarIcon?

SetToolbarIcon-code
Code: [Select]
        public static Boolean changeToolbarIcon(String cuiName, String toolbarName, String buttonName,
                                                String newSmallIconFileName, String newLargeIconFileName)
        {
            Boolean result = false;
            IAcadApplication iApp = (IAcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
            try
            {
                foreach (IAcadToolbarItem iAcadToolbarItem in ((IAcadToolbar)((IAcadMenuGroup)iApp.MenuGroups.Item(cuiName)).Toolbars.Item(toolbarName)))
                {
                    if ((iAcadToolbarItem.TagString == buttonName) || (iAcadToolbarItem.Name == buttonName))
                    {
                        iAcadToolbarItem.SetBitmaps(newSmallIconFileName, newLargeIconFileName);
                        result = true;
                        break;
                    }
                }
            }
            catch (Exception ex)
            { Log.LogException(ex, "ZusatzInfo: Buttonname[" + buttonName + "], newSmallIconFileName[" + newSmallIconFileName + "], newLargeIconFileName[" + newLargeIconFileName + "]"); }           
           return result;
        }

regards Mario
« Last Edit: December 21, 2017, 11:35:55 AM by MarioR »

MarioR

  • Newt
  • Posts: 65
Re: Problem with IAcadToolbarItem.SetBitmap and 2017-PNG-Icons
« Reply #1 on: December 25, 2017, 02:51:01 PM »
Hello,

i have found a solution, stupid, but works. :idiot2:
Rename the *.png to *.bmp and it's works.

I wish an merry christmas and a happy new year to all. :angel: