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: 

Context menu entry using C#?

1 REPLY 1
Reply
Message 1 of 2
bsee1
648 Views, 1 Reply

Context menu entry using C#?

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);
}
}

 

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
1 REPLY 1
Message 2 of 2
bsee1
in reply to: bsee1

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

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1

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

Post to forums  

Autodesk Design & Make Report