Revit generally does not display all graphics or elements in any views by default. Each Revit template regardless of Architectural, Structural or MEP has its own Graphics/Element display settings. It makes sense most of times by doing so to meet the requirements of different disciplines.
However, sometimes, we may want to show up some types of elements such as Mass in some views that do not turn them on, or in the extreme case, show up all types of elements and in turn categories in a specific view or all of them. Here are a couple of help methods to use in this regard.
public class SettingAdjuster
{
public static void TurnOnAllGraphics(Autodesk.Revit.DB.View view)
{
foreach (Category cat in view.Document.Settings.Categories)
if( cat.get_AllowsVisibilityControl(view) )
cat.set_Visible(view, true);
//view.setVisibility(cat, true);
}
public static void TurnOnAllGraphicsInActiveView(RvtDocument doc)
{
TurnOnAllGraphics(doc.ActiveView);
}
}
Here is some sample caller code.
...
SettingAdjuster.TurnOnAllGraphicsInActiveView(CachedDoc);
…
After the code is executed, all will be visible in the Visibility/Graphic Overrides window.
Revit Addin Wizard (RevitAddinWizard) provides various wizards, coders and widgets to help program Revit addins. It can be downloaded from the Download link at the bottom of the blog index page.
Hi
is it possible to manipulate the categories inside a linked file. for example i need to turn of all Floors of the linked file.
to clarify more i do the following manual steps
1. visibility graphics
2. Revit links Tab.
3. Click/change "by Host View" display setting of the related revit link file.
4. select custom.
5. goto Model Categories tab.
6. change from to Custom.
7. uncheck floors.
it will be really saving time if i can do that pragmatically.
Posted by: Moustafa Khalil | 05/20/2015 at 01:11 AM
Hi Moustafa, we got what you'd like to do but were afraid of that it's not possible with the Revit APIs published so far. In fact, we also found out, even for some very simple operations such as adding and adjusting Revit links, the API capabilities were pretty limited.
Posted by: Spiderinnet | 05/20/2015 at 09:05 PM
Thanks for your Reply....i hope Autodesk consider that in their future releases.
Posted by: Moustafa Khalil | 05/21/2015 at 12:35 PM
No problem. Yes, let's hope so.
Posted by: Spiderinnet | 05/22/2015 at 02:17 AM
Hi there,
thanks for this nice brief post! Do you know a way to switch main categories (Model, Annotation, Analytical, ...) visibility? I mean for example changing "Show analytical model categories in this view" in Visibility/Graphics Overrides dialog.
Thanks :)
Posted by: Serhan | 03/11/2016 at 09:33 AM
Serhan, it's surely possible. You can check the category type to see if it's model, annotation, or analytical and decide to hide or show.
Posted by: Spiderinnet | 03/11/2016 at 03:42 PM
Was this resolved, i want to control the visibility of categories in a linked file.
Posted by: Joshua Lumley | 05/21/2017 at 06:22 AM
Joshua, not sure which issue was your exact concern. In terms of the visibility control in Revit API however, it's likely that no much changes in recent versions.
Posted by: Spiderinnet | 05/21/2017 at 02:45 PM