Can't get OnExecute event to fire for my add-in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm new to Inventor and Inventor plug-ins, but I'm an experienced C++ add-in developer for 3ds Max, and I'm also an experienced C# developer. I'm using Visual Studio Pro 2012 with C# as my development language.
I've created a project using the project template, updated the manifest and addin files as appropriate, and made Inventor recognize and load my add-in. I can add a button definition, and add that button to a new panel in a ribbon, and it shows up. However, even though I assign a new delegate to the OnExecute event on the button definition, clicking my button does not call my handling function. I'm sure it's something simple I'm doing wrong, but I've read the documentation and sample code and threads on this forum, and can't figure out what it is.
If someone could help me out with this, I'd really appreciate it, because I don't even know how to debug this problem 😞 I attached the entire StandardAddInServer.cs file to this message, but here's the bit that I think matters:
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
m_inventorApplication = addInSiteObject.Application;
if (firstTime)
{
var assemblyRibbon = m_inventorApplication.UserInterfaceManager.Ribbons["Assembly"];
var inspectTab = assemblyRibbon.RibbonTabs["id_TabInspect"];
var exportPanel = inspectTab.RibbonPanels.Add("Export", "ToolsTabExportPanel", "SketchExportSVG");
var bitmap = new System.Drawing.Bitmap(GetType(), "ExportIcon.bmp");
var exportCommand = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition(
"Sketches to SVG", "SketchExportSVG", CommandTypesEnum.kQueryOnlyCmdType,
"6ab42c21-d44d-4b7b-b18b-f50212ae07eb", "Export sketches as SVG",
"Export sketches as SVG");
exportCommand.OnExecute += exportCommand_OnExecute;
exportCommand.Enabled = true;
exportPanel.CommandControls.AddButton(exportCommand);
}
}
void exportCommand_OnExecute(NameValueMap Context)
{
m_inventorApplication.ErrorManager.AddMessage("Hello, world!", false);
m_inventorApplication.ErrorManager.Show("Results", true, false);
}