Inventor Customization

Inventor Customization

Active Contributor
Posts: 32
Registered: ‎10-27-2011
Message 1 of 1 (294 Views)

Linking command to button in C#

294 Views, 0 Replies
02-06-2012 05:44 AM



I'm new to C# and I'm currently in the process of changing my VBA programs over to C#. I've successfully created a button on a command bar and now want to link a command to said button. I just can't seem to get it to work. Below is my activate method in StandardAddInServer.cs. What do I have to add to this method or to StandardAddInServer.cs to get a command within the project to execute when the button is pressed. 

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;
m_inventorApplication.Caption = "Addin Loaded";

m_ClientID = "61b5b9f4-3e8e-4d83-b856-52ef7b06238a";
ControlDefinitions controlDef = m_inventorApplication.CommandManager.ControlDefinitions;
oButton = controlDef.AddButtonDefinition("Mark Number", "MarkNumber", CommandTypesEnum.kQueryOnlyCmdType, m_ClientID,"Generate Mark #", "Mark #");
if (firstTime==true){
CommandBars comBars = m_inventorApplication.UserInterfaceManager.CommandBars;
CommandBar comBar = comBars.Add("IBG Add-Ins", "IBGADDINS", CommandBarTypeEnum.kRegularCommandBar, m_ClientID);
comBar.Visible = true;

// TODO: Add ApplicationAddInServer.Activate implementation.
// e.g. event initialization, command creation etc.



Any help will be greatly appreciated. Thank you.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.