Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Linking command to button in C#

0 REPLIES 0
Reply
Message 1 of 1
bennywise578
617 Views, 0 Replies

Linking command to button in C#

Hey,

 

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;
comBar.Controls.AddButton(oButton);
oButton.Execute();
}

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

 

 

Any help will be greatly appreciated. Thank you.

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report