Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been looking at InventorAddIn1, and at a certain point I read:
public void ExecuteCommand(int commandID)
{
// Note:this method is now obsolete, you should use the
// ControlDefinition functionality for implementing commands.
}
But for the life of me I can't find any C# examples of how to add a command (and presumably a button) using ControlDefinitions. I've found fragments, but I get lost in the disjointedness of it.
So far I've got to this...
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
// This method is called by Inventor when it loads the addin.
// The AddInSiteObject provides access to the Inventor Application object.
// The FirstTime flag indicates if the addin is loaded for the first time.
// Initialize AddIn members.
m_inventorApplication = addInSiteObject.Application;
var cmdMgr = m_inventorApplication.CommandManager;
Icon BigIcon = new Icon("Icon1.ico");
Icon SmallIcon = new Icon("Icon1.ico");
m_sampleButton = cmdMgr.ControlDefinitions.AddButtonDefinition("Command 1",
"Command 1",
CommandTypesEnum.kFilePropertyEditCmdType,
Guid.NewGuid().ToString(),
"Command 1 description",
"Command 1 Tooltip",
BigIcon, SmallIcon);
// TODO: Add ApplicationAddInServer.Activate implementation.
MessageBox.Show ("Hello from icony");
}
...and presumably there is a way of adding the button to the ribbon and a way of associating the button to a custom command (using the mysterious ControlDefinition method).
So,
Q1) how do I add a button to the ribbon?
Q2) how to I associate my command to the button?
Help!
Solved! Go to Solution.