Inventor Customization

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

Linking command to button in C#

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

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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube