<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Filter elements for a linked model in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-for-a-linked-model/m-p/13659972#M84049</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15967222"&gt;@adrian_ortega32GAWA&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-start="83" data-end="189"&gt;&lt;BR /&gt;1. To filter elements from a linked document, you need to pass the &lt;CODE data-start="147" data-end="158"&gt;linkedDoc&lt;/CODE&gt; object (of type &lt;CODE data-start="175" data-end="185"&gt;Document&lt;/CODE&gt;) in the FilteredElementCollector.&lt;/P&gt;
&lt;P data-start="83" data-end="189"&gt;2. You can use &lt;CODE data-start="206" data-end="239"&gt;uidoc.Selection.SetReferences()&lt;/CODE&gt; to highlight elements present in the linked document.&amp;nbsp;I believe this functionality was added in Revit 2023.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;

// Get the first linked Revit document
RevitLinkInstance linkInstance = new FilteredElementCollector(doc).OfClass(typeof(RevitLinkInstance))
    .WhereElementIsNotElementType().FirstElement() as RevitLinkInstance;

Document linkedDoc = linkInstance?.GetLinkDocument();            

// Get all wall elements from the linked document
var walls = new FilteredElementCollector(linkedDoc)
    .OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType();

// Create linked references for selection
var references = walls
    .Cast&amp;lt;Element&amp;gt;()
    .Select(e =&amp;gt; new Reference(e).CreateLinkReference(linkInstance)).ToList();

// Highlight the linked wall elements in the UI
uidoc.Selection.SetReferences(references);&lt;/LI-CODE&gt;
&lt;P data-start="83" data-end="189"&gt;&lt;BR /&gt;3.&amp;nbsp;You can use an intersection filter to determine whether elements in the main document and the linked document intersect.&amp;nbsp;This below sample code works by selecting an element in the linked document&lt;BR /&gt;and detecting all elements in the host document it intersects with. (Please note, this sample code is very simple and can be further enhanced and customized by implementing your own logic; This is just for your reference;)&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;

// Get the first Revit link instance in the current document
var linkInst = new FilteredElementCollector(doc)
    .OfClass(typeof(RevitLinkInstance))
    .WhereElementIsNotElementType()
    .FirstOrDefault() as RevitLinkInstance;

 Document linkedDoc = linkInst.GetLinkDocument();

// Let user select one element from the linked model           
Element linkedElement = linkedDoc.GetElement(uidoc.Selection.PickObject(ObjectType.LinkedElement, "Linked").LinkedElementId);

// Extract solid geometry from the linked element
Options geomOptions = new Options { ComputeReferences = true, View = doc.ActiveView, IncludeNonVisibleObjects = true };
Solid linkedSolid = (linkedElement.get_Geometry(geomOptions)?.
    OfType&amp;lt;Solid&amp;gt;().FirstOrDefault());

// Transform linked solid into host document coordinates
Solid transformedSolid = SolidUtils.CreateTransformed(linkedSolid, linkInst.GetTransform());

// Find elements in the main model that intersect with the selected linked element from the linked model.     
var intersectingElements = new FilteredElementCollector(doc)
    .WherePasses(new ElementIntersectsSolidFilter(transformedSolid))
    .WhereElementIsNotElementType();&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 01 Jun 2025 12:10:36 GMT</pubDate>
    <dc:creator>naveen.kumar.t</dc:creator>
    <dc:date>2025-06-01T12:10:36Z</dc:date>
    <item>
      <title>Filter elements for a linked model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-for-a-linked-model/m-p/13652299#M14</link>
      <description>&lt;P&gt;Hey! I'm new to revit;&lt;/P&gt;&lt;P&gt;I've being learning MEP Design, and stumbled upon Clash detections for a personal project, I have a structural model, which's workset is Shared levels and grids. I'm needing to highlight beams and structural elements so that my systems do not clash, but haven't been able to find how to do so. I tried this solution&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/revit-architecture-forum/create-filter-for-linked-revit-file/td-p/10452608," target="_blank"&gt;https://forums.autodesk.com/t5/revit-architecture-forum/create-filter-for-linked-revit-file/td-p/10452608 with no luck.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance, I'm using Revit 2022&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 20:02:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-for-a-linked-model/m-p/13652299#M14</guid>
      <dc:creator>adrian_ortega32GAWA</dc:creator>
      <dc:date>2025-05-27T20:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Filter elements for a linked model</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-for-a-linked-model/m-p/13659972#M84049</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15967222"&gt;@adrian_ortega32GAWA&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P data-start="83" data-end="189"&gt;&lt;BR /&gt;1. To filter elements from a linked document, you need to pass the &lt;CODE data-start="147" data-end="158"&gt;linkedDoc&lt;/CODE&gt; object (of type &lt;CODE data-start="175" data-end="185"&gt;Document&lt;/CODE&gt;) in the FilteredElementCollector.&lt;/P&gt;
&lt;P data-start="83" data-end="189"&gt;2. You can use &lt;CODE data-start="206" data-end="239"&gt;uidoc.Selection.SetReferences()&lt;/CODE&gt; to highlight elements present in the linked document.&amp;nbsp;I believe this functionality was added in Revit 2023.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;

// Get the first linked Revit document
RevitLinkInstance linkInstance = new FilteredElementCollector(doc).OfClass(typeof(RevitLinkInstance))
    .WhereElementIsNotElementType().FirstElement() as RevitLinkInstance;

Document linkedDoc = linkInstance?.GetLinkDocument();            

// Get all wall elements from the linked document
var walls = new FilteredElementCollector(linkedDoc)
    .OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType();

// Create linked references for selection
var references = walls
    .Cast&amp;lt;Element&amp;gt;()
    .Select(e =&amp;gt; new Reference(e).CreateLinkReference(linkInstance)).ToList();

// Highlight the linked wall elements in the UI
uidoc.Selection.SetReferences(references);&lt;/LI-CODE&gt;
&lt;P data-start="83" data-end="189"&gt;&lt;BR /&gt;3.&amp;nbsp;You can use an intersection filter to determine whether elements in the main document and the linked document intersect.&amp;nbsp;This below sample code works by selecting an element in the linked document&lt;BR /&gt;and detecting all elements in the host document it intersects with. (Please note, this sample code is very simple and can be further enhanced and customized by implementing your own logic; This is just for your reference;)&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;

// Get the first Revit link instance in the current document
var linkInst = new FilteredElementCollector(doc)
    .OfClass(typeof(RevitLinkInstance))
    .WhereElementIsNotElementType()
    .FirstOrDefault() as RevitLinkInstance;

 Document linkedDoc = linkInst.GetLinkDocument();

// Let user select one element from the linked model           
Element linkedElement = linkedDoc.GetElement(uidoc.Selection.PickObject(ObjectType.LinkedElement, "Linked").LinkedElementId);

// Extract solid geometry from the linked element
Options geomOptions = new Options { ComputeReferences = true, View = doc.ActiveView, IncludeNonVisibleObjects = true };
Solid linkedSolid = (linkedElement.get_Geometry(geomOptions)?.
    OfType&amp;lt;Solid&amp;gt;().FirstOrDefault());

// Transform linked solid into host document coordinates
Solid transformedSolid = SolidUtils.CreateTransformed(linkedSolid, linkInst.GetTransform());

// Find elements in the main model that intersect with the selected linked element from the linked model.     
var intersectingElements = new FilteredElementCollector(doc)
    .WherePasses(new ElementIntersectsSolidFilter(transformedSolid))
    .WhereElementIsNotElementType();&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Jun 2025 12:10:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-elements-for-a-linked-model/m-p/13659972#M84049</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2025-06-01T12:10:36Z</dc:date>
    </item>
  </channel>
</rss>

