Which button is clicked?

Which button is clicked?

Anonymous
Not applicable
2,587 Views
7 Replies
Message 1 of 8

Which button is clicked?

Anonymous
Not applicable

The addin I am writing adds a ribbon panel with two buttons (button A and button B) to the "Add-Ins Ribbon".

 

Clicking these buttons will both execute the "Public Function Execute(commandData As Autodesk.Revit.UI.ExternalCommandData, ByRef message As String, elements As Autodesk.Revit.DB.ElementSet) As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute"

 

I would like to know which button is being clicked (A or B).

 

How can I determine this?

 

P.s. In my .addin manifest, I have defined only one "Command", so under the "External Tools", only one command show up (as expected).

0 Likes
Accepted solutions (1)
2,588 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

To my knowlege this info isn't passed on by the API. There are ways around it though as discussed in this post from a couple years back:  http://forums.autodesk.com/t5/Revit-API/Which-pushbutton-caused-the-ExternalCommand/m-p/3698908

 

Is there a reason that you can't just have a separate command for each button?

0 Likes
Message 3 of 8

Anonymous
Not applicable

Having a separate command for each button is no problem...

 

...except that I don't even know how my current buttons are currently "linked" by the  ".addin manifest" to the "Execute command".

 

The way my addin looks right now: a panel with two buttons on the Addin Ribbon and one command under the "External Tools"...but they are ALL connected to one and the same Execute command.

 

I hope you understand what I am trying to say. Maybe you can show me an example of having multiple commands (linked to different buttons)?

0 Likes
Message 4 of 8

Anonymous
Not applicable
Accepted solution

I typically create an Addin Application and then have all command buttons created and associated to the commands during the OnStartup method of the addin. I have linked an example visual studio 2010 solution set up for Revit 2014, it's very bare bones but take a look to see how it's done.

 

0 Likes
Message 5 of 8

Anonymous
Not applicable

Right! That example makes perfect sense. I was writing all the code in one class, you wrote a class for each button/command.

The only thing missing in your example is the ".addin manifest", but I bet I can recreate it.

 

Thanks a ton for sharing that example!

0 Likes
Message 6 of 8

Anonymous
Not applicable

No worries glad to help.

 

BTW I did include a manifest in the zip file it is called RibbonExample.addin

 

0 Likes
Message 7 of 8

jeremy_tammik
Alumni
Alumni

Dear Teun Ham,

 

This question has actually been discussed a couple of times in the past, so I added an explanation of it to The Building Coder as well:

 

http://thebuildingcoder.typepad.com/blog/2013/01/url-and-other-buttons-xyz-points-and-vectors.html#2

 

Best regards,

 

Jeremy

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 8 of 8

Anonymous
Not applicable

@Anonymous wrote:

No worries glad to help.

 

BTW I did include a manifest in the zip file it is called RibbonExample.addin

 


Aaah, I missed it completely. I guess I expected it was an ".suo" file (Visual Studio Solution User Option). I will pay better attention to the file extension next time 🙂

0 Likes