Python Addin Button onto existing c# addin toolbar

1031
2
03-04-2014 06:32 AM
FaizanTayyab
Occasional Contributor
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
Occasional Contributor III
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
Occasional Contributor
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