Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have been trying to hide the host element of the door in the attached family. For some reason my code is not able to do it, however, I am able to hide the wall as a user in the RevitUI.
Extremely appreciate every help in advance!
Document document = App.RevitAddIn.RevitEnvironment.GetActiveDocument(true);
if (document != null)
{
View activeView = document.ActiveView;
//For simplification, I selected every wall category since there is only one instance
//of a wall in this FamilyFile
Element e = new FilteredElementCollector(document, activeView.Id)
.OfCategory(BuiltInCategory.OST_Walls)
.WhereElementIsNotElementType()
.ToElements().FirstOrDefault();
using (var transaction = new Transaction(document, "Hide a wall"))
{
try
{
transaction.Start();
if(e!=null && !e.IsHidden(activeView) && e.CanBeHidden(activeView))
{
activeView.HideElements(new List<ElementId>() { e.Id });
transaction.Commit();
}
}
catch (Exception ex)
{
transaction.RollBack();
throw new Exception("Hiding a wall.", ex);
}
}
Solved! Go to Solution.