Deal with duplicate ribbon panel names

Deal with duplicate ribbon panel names

george.potts
Enthusiast Enthusiast
675 Views
5 Replies
Message 1 of 6

Deal with duplicate ribbon panel names

george.potts
Enthusiast
Enthusiast

Hi all!

I have a ribbon panel editor to show/hide ribbon tabs within an in-house addin, we have lots of other paid tools and the ribbon is really ful. I noticed I'd have duplicate version for the family based panels in a regular window.

georgepotts_0-1684490414827.png

To remove the duplicates I did:

if (!ribbonCheckboxList.Items.Contains(tab.Title))
{
     ribbonCheckboxList.Items.Add(tab.Title);
}

When this list is built, the duplicates are removed, however the effect is present on both with the same name, as I do the following:

 

string CurrentlySelectedTab = (string)ribbonCheckboxList.Items[e.Index];
                if (sdsstring != CurrentlySelectedTab.ToLower())
                {
                    foreach (RibbonTab tab in Autodesk.Windows.ComponentManager.Ribbon.Tabs)
                    {
                        Debug.WriteLine(tab.Title);
                        if ((CurrentlySelectedTab == tab.Title) && (e.CurrentValue == CheckState.Checked))
                        {
                            tab.IsVisible = false;
                        }

                        if ((CurrentlySelectedTab == tab.Title) && (e.CurrentValue == CheckState.Unchecked))
                        {
                            tab.IsVisible = true;
                        }
                    }
                }

 

A simple on or off when clicked and everything works.
Now as it searches for Title, both panels are added or removed, resulting in this, duplicate versions. This is my error I'd like to fix:

georgepotts_1-1684490536380.png

Is there a way of detecting the family versions of the panels or should I be storing the tab.UID property instead? Obviously this would assume the first iteration of the "Annotate" panel is the "normal" one correct? I'd prefer to have a detection for family based as this would require it working in the family version as well.

Accepted solutions (1)
676 Views
5 Replies
Replies (5)
Message 2 of 6

dtartaglia_PYEBEB5KA84W
Enthusiast
Enthusiast

I do not know if there is an answer to this besides making your in-house custom panel names unique. You could prepend your company initials or in some other way?

Message 3 of 6

george.potts
Enthusiast
Enthusiast

The duplicates are of official autodesk ribbon tabs, except they are the ones that appear when in a family model. They are normally hidden based on the type of model open, however as I am searching by Title property, the issue of these becoming duplicates occours. Its doesn't have anything to do with the number of addins.

I think I might build a test version with the UID property, export to JSON to read back and fourth from.

 

If anyone else has any better ideas do comment them!

0 Likes
Message 4 of 6

ricaun
Advisor
Advisor
Accepted solution

You should use the Id, I'm pretty sure the Id is different for each RibbonTab. And the Title could change depending on the Revit language.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 5 of 6

dtartaglia_PYEBEB5KA84W
Enthusiast
Enthusiast

One last question, you obviously researched a lot here. Does tab have an id property that could be used?

Message 6 of 6

george.potts
Enthusiast
Enthusiast

georgepotts_0-1684508015673.png

Looks like thats the one thank you!