Inventor Customization

Reply
Mentor
bsee1
Posts: 212
Registered: ‎11-14-2011
Message 1 of 2 (265 Views)

Context menu entry using C#?

265 Views, 1 Replies
04-27-2012 08:57 AM

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
Mentor
bsee1
Posts: 212
Registered: ‎11-14-2011
Message 2 of 2 (251 Views)

Re: Context menu entry using C#?

04-30-2012 08:58 AM 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.