BIM World
A Professional BIM Learning Platform


Revit API Tutorial: Managing Hidden Elements in Elevation Views

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!

xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat
Like(0) 打赏
BIM WORLD » Revit API Tutorial: Managing Hidden Elements in Elevation Views

Comment Get first!

Must log in before commenting!

 

BIM World, A Professional BIM Learning Platform

Stay updated on the latest architecture trends and share new building technologies.

Contact UsAbout Us

觉得文章有用就打赏一下小编吧

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

Account Login

By signing in, you agree toUser Agreement

Sign Up