Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get Ribbon Button Click Event in API

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
VinoVinoth92
4174 Views, 12 Replies

Get Ribbon Button Click Event in API

Hi,

 

I need to find the ribbon button click event in revit API. Kindly help me to accomplish this.

 

Thanks and Regards,

Vinoth Kumar.R 

12 REPLIES 12
Message 2 of 13

Hi @VinoVinoth92,

This previous post should give you what you need:

http://forums.autodesk.com/t5/revit-api-forum/recording-executed-commands/m-p/6675159/highlight/true...

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 13

Hi Matt,

 

Thanks for the reply. I have not found the event "ItemExecuted" which was mentioned in that link for RibbonItem or RibbonButton classes which was available in Autodesk.Windows dll. Whatever we are adding to existing panels for those items we can get the click event. But for the items which are available default in Revit for those i am not able to find the click event.

 

Thanks and Regards,

Vinoth Kumar.R

Message 4 of 13

Hi Vinoth,

Here's a snippet to get you started. I actually use the UIElementActivated event:

 

Imports Autodesk.Revit.Attributes
Imports Autodesk.Revit
Imports adWin = Autodesk.Windows
<Transaction(TransactionMode.Manual)> _
<Regeneration(RegenerationOption.Manual)> _
<Journaling(JournalingMode.UsingCommandData)> _
<DisplayName("Application Name")> _
<Description("Application Description")> _
Public Class YourApp
    Implements UI.IExternalApplication
  Public Function OnStartup(ByVal a As UI.UIControlledApplication) As UI.Result Implements UI.IExternalApplication.OnStartup
                  'event handler
            AddHandler adWin.ComponentManager.UIElementActivated, AddressOf ComponentManager_UIElementActivated
      Return UI.Result.Succeeded
  End Function
  Public Function OnShutdown(ByVal a As UI.UIControlledApplication) As UI.Result Implements UI.IExternalApplication.OnShutdown
                  RemoveHandler adWin.ComponentManager.UIElementActivated, AddressOf ComponentManager_UIElementActivated
    Return UI.Result.Succeeded
  End Function
  Private Sub ComponentManager_UIElementActivated(ByVal sender As Object, ByVal e As Autodesk.Windows.UIElementActivatedEventArgs)
         'do your thing with the e
  end sub
end class

 

Let us know how you get on.

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 5 of 13

Hi Matt,

 

The code you have provided does not work. Thanks for the reply.

 

Thanks and Regards,

Vinoth Kumar.R

Message 6 of 13

Hi @VinoVinoth92,

'Does not work'? You're going to have to explain better than that!

 

I can assure you that it does work. I use it myself.

Explore the e object in the ComponentManager_UIElementActivated function.

Put a break mark in there and browse the objects.

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 7 of 13

Hi Matt,

 

The code you have provided which will work only for the items you are going to add to the RibbonPanels into Revit. But the query was different. I have to get the click events for the items which are available in Revit by Default. Please refer the attached image.

 

 

Thanks and Regards,

Vinoth Kumar.R

Message 8 of 13

@VinoVinoth92,

You are wrong. I use it to trap all ribbon item clicks.

Such as this:

Modify > Modify > Delete (Modify tab, Modify Panel, Delete item)

 

You will need to investigate further.

 

Cheers,

 

-Matt

 

 


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 9 of 13

Hi Matt,

 

Apologies. Your are not wrong. 

 

Thanks and Regards,

Vinoth Kumar.R

Message 10 of 13

Matt (@matthew_taylor) , thank you for your example on monitoring UI Click Events!

 

There is a button id like to monitor which does not trigger the event. It is the Settings button in the MEP Fabrication Parts Dockable Dialog (Screenshot below). Have you found this to be true also? Ive examined the e object and looked at other members of  'Autodesk.Windows' but nothing pops out to me. 

 

Any thoughts?

MonitorUiClick.png

Message 11 of 13

Hello @TheRealChrisHildebran ,

This method will not work for what you are trying to do.

I would suggest exploring the posts under this category:

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.32

 

Regardless, I would suggest you don't even need to do this using dialogs. Check out the FabricationConfuguration object. Not something I've had dealings with, but it may have what you need. https://www.revitapidocs.com/2020/119c73a2-a113-aa8c-e032-e80d22e31ac8.htm 

 

Regardless of your decided method, I suggest that any issues you come up against should be in their own forum post. That way you'll have multiple people looking at it.


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 12 of 13

Thanks for the feedback Matt! 

 

I definitely do look at Jeremy's gold mine and refer to the Revit API docs daily and incidentally. They are both tabs that open immediately upon opening my browser. 😁 In this case there is no event in the Revit API Class you linked to.

 

Normally i would have opened a new post but i think my question just extended the original post a bit keeping them connected.

 

Simply wanted to see if you had any experience with your solution to the OP working on non-Ribbon items.

Message 13 of 13

Ah, I have seen your other post which spells out your purpose. I'll reply there.

Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community