Select to view content in your preferred language

Python Addin Button onto existing c# addin toolbar

1166
2
03-04-2014 06:32 AM
FaizanTayyab
Deactivated User
Hi,

I wanted to know if it is possible to add a python addin Button onto an existing addin toolbar programatically?

Thanks
0 Kudos
2 Replies
AhmedEl-Sisi
Deactivated User
You can add python addin Button as normal button to existing toolbar in ArcMap.

Get Your Toolbar using ESRI sample Code:
public ESRI.ArcGIS.Framework.ICommandBar GetToolbarByName(ESRI.ArcGIS.Framework.IApplication application, System.String toolbarName)
{
  ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars;
  ESRI.ArcGIS.esriSystem.UID barID = new ESRI.ArcGIS.esriSystem.UIDClass();
  barID.Value = toolbarName; // Example: "esriArcMapUI.StandardToolBar  or TestAddin__Custom_Toolbar"
  ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(barID, false, false);
  if (commandItem != null && commandItem.Type == ESRI.ArcGIS.Framework.esriCommandTypes.esriCmdTypeToolbar)
  {
    return (ESRI.ArcGIS.Framework.ICommandBar)commandItem;
  }
  else
    return null;
}


Then you get your Button By Its id and Add it to the toolbar:

ESRI.ArcGIS.Framework.ICommandBar myToolbar=GetToolbarByName(m_Application,"TestAddin__Custom_Toolbar");

                UID CommandUid = new UIDClass();
                //Get Your Button
                CommandUid.Value ="TestAddin_addin.button";
                //Add your command or button
                myToolbar.Add(CommandUid);


Regards,
0 Kudos
FaizanTayyab
Deactivated User
Thanks I already had tried that but it doesn't work for the custom python addin, maybe it is version issue, the toolbar is done using C# and targeted for minimum version 10 whereas the python addin had been done using version 10.2.

Thanks
0 Kudos