« Family API Nested Type, Instance and Symbol Retrieval | Main | Recursively Disable Architecture Mismatch Warning »

July 03, 2013

Comments

Hi Jeremy,

Great article, thanks...

How do you think we could dynamically hide the ribbon panel based on the type of Revit file that is opened (family, project) ? For instance if you want to show it only when a family document is active, and without any toggle button.

Even with a Ribbon panel global instance in the "App" class, I don't see where to make it visible/unvisible without a toggle button to control it. In the "Command" class ? With an updater ?

Thanks.

Dear Maxime,

Thank you for your appreciation! Glad you like it.

As mentioned above, you can activate and deactivate individual buttons using command availability classes.

In those classes you can implement any kind of checking functionality you desire, e.g. using the type of Revit document opened, the time of day, or any other trigger.

Maybe you can call the RibbonPanel.Visible property from withing a command availability class?

Please do let us know how you fare with this! Thank you!

Cheers, Jeremy.

Hi Jeremy,

I tried what you said, creating this command availability class :
class FamilyOnlyAvailability : IExternalCommandAvailability
{
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
// we want to display the rp when a family doc is active
bool result = (null != applicationData.ActiveUIDocument) && applicationData.ActiveUIDocument.Document.IsFamilyDocument;

// hide or display the ribbonpanel
List liste_rp = applicationData.GetRibbonPanels();
foreach (RibbonPanel rp in liste_rp)
{
if (rp.Name == Util.Caption)
{
if (!result)
rp.Visible = false;
else rp.Visible = true;

break;
}
}

return result;
}
}

The problem is once the Ribbon panel has been hidden, the command availability class is no more used... so it can't be displayed again... :(

Dear Maxime,

Thank you for this very cool partial result.

Ok, so you can hide it successfully.

Now you can try to implement something to display it again, e.g. using a separate command button in a separate main control panel of your application.

This sounds pretty useful to me, provided your application is large and complex enough to warrant multiple panels, some of which you wish to sometimes hide.

Cheers, Jeremy.

Hi Jeremy.

That would be a good trick, but this is not what I want to do. My idea was to completely hide the ribbon panel except when there is a family document active, because it is the only case where the commands in the rp can be used. I don't want to add a button to control visibility because we now have plenty of ribbon panels and commands in the add-in tab, so lighten it becomes quite necessary...

I think it would be nice if there was a IRibbonPanelAvailability class to implement, which would be the equivalent of IExternalCommandAvailability but for panels.

Cheers.

Maxime

Dear Maxime,

Thank you for your research and clear analysis.

I submitted the wish list item CF-6 [API wish: ribbon panel availability class] for you for the requested functionality.

Cheers, Jeremy.

Dear Jeremy,

Thanks a lot for your help and for submitting the request.

Cheers.

Maxime

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource