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: 

Hiding buttons when document view changes

7 REPLIES 7
Reply
Message 1 of 8
raunoveb
987 Views, 7 Replies

Hiding buttons when document view changes

We are developing a plugin for Revit 2015 and trying to hide certain buttons from our custom RibbonTab depending on the type of open document. For that we intended to create an event handler that checks ViewActivated event. Firstly can we even use this event to differentiate between family view and model view? Secondly if we can indeed use this event, where should be the correct place to create the EventHandler?

7 REPLIES 7
Message 2 of 8
Scott_Wilson
in reply to: raunoveb

You can register for these kinds of events in either UIControlledApplication or UIApplication.

 

You can differentiate between family documents and project documents using the Document.IsFamilyDocument property, the parameters passed to your event handlers should give you a path to the active document.

 

 

Message 3 of 8
Revitalizer
in reply to: raunoveb

Hi raunoveb,

 

what about an availability class ?

 

TBC says:

 

"To disable and hide your button, you can make use of an availability class, i.e. a class implementing the IExternalCommandAvailability interface and the PushButton.AvailabilityClassName property specifying its name:

That will allow you to toggle the visibility and availability of your class at will, just as you require."

 

http://thebuildingcoder.typepad.com/blog/2014/06/room-editor-live-and-unofficial-custom-ribbon-butto...

 

No need to subcribe to any sort of event this way.

 

 

Best regards,

Revitalizer

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 8
Scott_Wilson
in reply to: Revitalizer

Hmm, I didn't know you could hide a button with IExternalCommandAvailability.  I've only ever used it for enabling / disabling. Is this standard functionality or are you simply using the IsCommandAvailable method to call other code that hides the button?

Message 5 of 8
raunoveb
in reply to: Scott_Wilson

We already made use of the IExternalCommandAvailability interface and it properly enables/disables these buttons but what we'd also like to do is to hide this button. How can we get the reference to the button inside IsCommandAvailable method?

Message 6 of 8
Revitalizer
in reply to: Scott_Wilson

Dear Scott,

 

yes, of course, with this availability class, you can only enable or disable buttons.

 

Changing the visibility at runtime is also possible since each RibbonItem has a Visible property.

This could be used to fill comboboxes or pulldownbuttons with a changing list of displayed items:

http://forums.autodesk.com/t5/revit-api/ribbon-combobox-clear-change-data/td-p/5061392

 

If one really wants to hide buttons, he has to subcribe to ViewActivated event and perform the steps you've already suggested.

 

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 8
Revitalizer
in reply to: raunoveb

Dear raunoveb,

 

you could either make you buttons global static variables, so you can access them from everywhere.

 

Or you can browse Ribbon structure by using UIControlledApplication.GetRibbonPanels(tabName).

Then browse each RibbonPanel for the button you need, either by its name or its text.

 

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 8 of 8
raunoveb
in reply to: Revitalizer

Yeah, thanks. I already used this solution. I just hoped there would be a more intelligent way to achieve this. Unfortunately there isn't.

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