Hide ribbon tab if family document active

Hide ribbon tab if family document active

juancalvoferrandiz
Enthusiast Enthusiast
939 Views
3 Replies
Message 1 of 4

Hide ribbon tab if family document active

juancalvoferrandiz
Enthusiast
Enthusiast

Hello everyone,

 

OBJECTIVE: To hide a external application (the tab in the ribbon) when a family document is open.

 

CONTEXT: I understand the XML tag "NotVIsibleInFamily", but it seem to work just for external commands:

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/Revit-API/files/GUID-...

 

Thanks.

 

Have a nice day.

 

Juan.

0 Likes
940 Views
3 Replies
Replies (3)
Message 2 of 4

aignatovich
Advisor
Advisor

Hi!

 

You can add a reference to UIFramework.dll (it is in the same folder as RevitAPI.dll)

 

Then you can control specific tab visibility:

var rc = RevitRibbonControl.RibbonControl;

var tab = rc.FindTab("<your tab name>");

tab?.IsVisible = false; // or true

It can be done in ViewActivated event handler, something like:

private void OnViewActivated(object sender, ViewActivatedEventArgs e)
        {
... tab.IsVisible = !e.Document.IsFamilyDocument; }
0 Likes
Message 3 of 4

juancalvoferrandiz
Enthusiast
Enthusiast

Ok. Thanks for your answer. At this moment I don't understand events as well as I would like. When I have time to study them properly I will try your idea. Thanks again. Have a nice week.

0 Likes
Message 4 of 4

Anonymous
Not applicable

You could also consider implementing an IExternalCommandAvailability class.  This class can be assigned to a button an will allow you to "compute" whether the button should be enabled or not.  You could check for family document there and disable the buttons (instead of hiding the tab which can lead to user confusion).

 

In your pushbutton data object you can set the availability class like this:

myCommandBtnData.AvailabilityClassName = "myNameSpace.myCommandAvailability";

 

the class looks like this:

 

    class myCommandAvailability : IExternalCommandAvailability
    {
        
        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
        {
                if (applicationData.ActiveUIDocument.Document.IsFamilyDocument)
                      return false;
        }

If you want to get fancy, you can keep a reference to the button and change the text or tooltip to help the user understand why they command is disabled in a particular situation.

 

 

0 Likes