BIM World
A Professional BIM Learning Platform


Revit API Tutorial: How to Select Specific Elements from Linked Files

Here is a brief explanation of how to select a specific element from a linked file, using Space as an example.
First, we need to create a custom selection filter class.

public class SelectionLinkFilter : ISelectionFilter
{
    Document linkDoc = null;

    public bool AllowElement(Element elem)
    {
        if (elem is RevitLinkInstance)
        {
            linkDoc = (elem as RevitLinkInstance).GetLinkDocument();
            return true;
        }
        return false;
    }

    public bool AllowReference(Reference reference, XYZ position)
    {
        if (linkDoc.GetElement(reference.LinkedElementId) is Space)
        {
            return true;
        }
        return false;
    }
}

Next, use this class when performing the selection:

UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Reference reference = uiDoc.Selection.PickObject(ObjectType.LinkedElement, new SelectionLinkFilter());
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: How to Select Specific Elements from Linked Files

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