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
Solved! Go to Solution.
Solved by matthew_taylor. Go to Solution.
Hi @VinoVinoth92,
This previous post should give you what you need:
Cheers,
-Matt
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
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
Hi Matt,
The code you have provided does not work. Thanks for the reply.
Thanks and Regards,
Vinoth Kumar.R
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
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
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
Hi Matt,
Apologies. Your are not wrong.
Thanks and Regards,
Vinoth Kumar.R
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?
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.
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.