Inventor Customization

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

Context menu entry using C#?

217 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: 208
Registered: ‎11-14-2011
Message 2 of 2 (203 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

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
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

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