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













Must log in before commenting!
Sign Up