- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We're trying to write a routine that takes a View3D and hides everything except the walls. I know it's easy enough to do that in the Revit UI, but the routine is part of a larger project. I've run into an exception that I'm not sure what to do about. My code looks like the sample code below.
Snippet
Public Sub HideEverythingExceptWalls(view As view3d) Dim categories = view.Document.Settings.Categories For Each cat As Category In categories If cat.Id.IntegerValue = BuiltInCategory.OST_Walls Then cat.Visible(view) = True Else cat.Visible(view) = False End If Next End Sub
When the loop gets to the "Piping Systems" category, an exception gets thrown that states ,
Autodesk.Revit.Exceptions.InvalidOperationException was unhandled by user code
HResult=-2146233088
Message=Cannot set the visible attribute of the category xyz because it is user hidden
I couldn't find any documentation on the exception, but I'm guessing that the problem is related to the fact that Piping Systems are not exposed in the visibility graphics UI (my guess could be wrong). Has anyone ever encountered this exception before or know of a way to prevent it?
Many thanks.
Solved! Go to Solution.