Context menu entry using C#?

Context menu entry using C#?

Anonymous
Not applicable
768 Views
1 Reply
Message 1 of 2

Context menu entry using C#?

Anonymous
Not applicable

I'm trying to add to a right click menu for an Inventor addin using C#. I'm basing mine off of a VB sample. However, it appears VB allows the add command to be missing values, whereas C# will not allow any empty values. Can soemone suggest what I should be doing to fix this?

 

The 3 commas in a row are where the error occurs. C# error is simple "argument missing".

 

ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;
            ButtonDefinition m_featureCountButtonDef = controlDefs.AddButtonDefinition("Add symbol", "symbolAddition", CommandTypesEnum.kQueryOnlyCmdType, "{DFJMQC00-938F-11E1-AFAA-FEFJSDE59B18}", "Count the features in the active part.", "Count Features");

if (firstTime)
            {
                try
                {
CommandBars commandBars = m_inventorApplication.UserInterfaceManager.CommandBars;
                    CommandBar commandBar = commandBars.Add("My Macros", "symbolAddition",,, "{DFJMQC00-938F-11E1-AFAA-FEFJSDE59B18}");
                    commandBar.Visible = true;
                    commandBar.Controls.AddButton(m_featureCountButtonDef);
}
}

 

0 Likes
769 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

I still don't have this working yet, though I did solve the missing parameter problem.

 

ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;
            string m_ClientID = "61a179db-d522-4ffa-b78e-7d782595f000";
            ButtonDefinition oButton = controlDefs.AddButtonDefinition("Add symbol", "symbolAddition", CommandTypesEnum.kQueryOnlyCmdType, m_ClientID, "Count the features in the active part.", "Count Features");

if (firstTime)
            {

                CommandBars commandBars = m_inventorApplication.UserInterfaceManager.CommandBars;
                CommandBar commandBar = commandBars.Add("My Macros", "symbolAddition", CommandBarTypeEnum.kRegularCommandBar, m_ClientID);
                commandBar.Visible = true;
                commandBar.Controls.AddButton(oButton);
}

 

Instead, it now gives me this error when Inventor starts:  http://dl.dropbox.com/u/46698764/InventorAddButtonError.png

 

Any help would be appreciated!

 

-Brandon

0 Likes