I want to change their color depending on the belonging to the project. I have already managed to assign a color in this way for the custom button panels being created:
foreach (var item in AW.ComponentManager.Ribbon.Tabs.Where(t => t.Name != null && t.Name.Contains(UpdaterButtonData.TabName)).First().Panels)
{
item.CustomPanelBackground = UpdaterApplication.GetRandomBrush();
item.CustomPanelTitleBarBackground = UpdaterApplication.GetRandomBrush();
}
but I can't figure out how to get a similar list of open viewports panels for open projects.
[Transaction(TransactionMode.Manual)]
public class CommandColor : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
var ribbon = AW.ComponentManager.Ribbon;
Border p1 = (Border)ribbon.Parent;
StackPanel p2 = (StackPanel)p1.Parent;
Grid p3 = (Grid)p2.Parent;
Grid p4 = (Grid)p3.Parent;
MainWindow mainWindow = (MainWindow)p4.Parent;
return Result.Succeeded;
}
}
Inside the debugger, I see the following set of UI elements
Thanks!
UPD:
It's funny that the following code:
foreach (AW.RibbonTab ribbonTab in listDelTab)
{
AW.ComponentManager.Ribbon.Tabs.Remove(ribbonTab);
}
in verbs removes the Tab from the Ribbon, but does it only visually, because all the deleted Tabs still remain somewhere inside the Ribbon.
If you try to add a Tab with the same name after deleting the Tab, you will get an exception, saying that a Tab with the same name already exists, despite the fact that you have already "deleted" it and it has even disappeared from Ribbon!
And moreover, if you try to add your Tabs a large number of times (I have 19), then you will get exceptions like:
Solved! Go to Solution.
Solved by Mohamed_Arshad. Go to Solution.
HI @ankofl
To Get List of Opened View, you need to use GetOpenUIViews() method.
IList<UIView> views= commandData.Application.ActiveUIDocument.GetOpenUIViews();
For Color Changing of the ViewTab you need to refer the @Moustafa_K post he clearly documented how to change color of the ViewTab.
MoustafaK Post URL: https://forums.autodesk.com/t5/revit-api-forum/how-to-change-revit-ribbon-tab-color/td-p/9761734
https://sharpbim.hashnode.dev/styling-revit-ui
Hope this will Helps 🙂
Can't find what you're looking for? Ask the community or share your knowledge.