Recently, I have been working on the sectional drawings for a project. Anyone who has experience with such projects knows how tedious drawing can be. Using Revit requires numerous detailed and labor-intensive steps. In this article, I want to share a small feature I developed to hide elevations within a section view.
First, gather all the elevations in the current view:
FilteredElementCollector coll = new FilteredElementCollector(doc);
coll.OfClass(typeof(Level)).OfCategory(BuiltInCategory.OST_Levels);
ICollection<ElementId> elementIds = coll.ToElementIds();
Next, remove the elevations you want to keep visible, leaving only those you wish to hide:
View view = doc.ActiveView;
LevelSelecionFilter levelSelectionFilter = new LevelSelecionFilter();
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "Select the elevations you do not want to hide!");
Level level = doc.GetElement(refer) as Level;
if (elementIds.Contains(level.Id)) {
elementIds.Remove(level.Id);
}
Then, start a transaction to hide the selected elevations in the view:
Transaction trans = new Transaction(doc);
trans.Start("Hide Elevations");
view.HideElements(elementIds);
trans.Commit();
This outlines the basic approach for hiding elevations. For beginners, you may also need to implement the LevelSelectionFilter class used above, as shown below:
class LevelSelecionFilter : ISelectionFilter
{
public bool AllowElement(Element elem)
{
if (elem is Level)
{
return true;
}
return false;
}
public bool AllowReference(Reference reference, XYZ position)
{
throw new NotImplementedException();
}
}
That covers the method for hiding elevations in a sectional drawing. Thank you for reading!













Must log in before commenting!
Sign Up