# Filter elements in view within the crop view

**URL:** <https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383>\
**Category:** Developers\
**Tags:** python, dynamo\
**Created:** [October 9, 2023, 12:18am UTC](https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383 "2023-10-09T00:18:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filla96](https://avatars.discourse-cdn.com/v4/letter/f/da6949/32.png) [@Filla96](https://forum.dynamobim.com/u/Filla96)\
**Post date:** [October 9, 2023, 12:18am UTC](https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383/1 "2023-10-09T00:18:50Z")

</div>

I have a simple script that filters elements from a linked model in multiple floor plans. I would like to consider the crop view when filtering these elements, therefore not retrieving elements outside of the crop view.

This is what I have at the moment in Revit 2021:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/8/e8df80e017b899b1bfca13d8d75950b507a02da1.png)

I would appreciate some help!

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [October 9, 2023, 1:55am UTC](https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383/2 "2023-10-09T01:55:21Z")

</div>

Hi @Filla96 welcome to the forum,

You have certainly picked a challenge for yourself and members of the forum.

The constructing of a filtered element collector of a view is limited to the current document - see forum post here [Collecting linked elements in view without knowing linked file instance?](https://forum.dynamobim.com/t/collecting-linked-elements-in-view-without-knowing-linked-file-instance/49992/2)

You could also look here on The Building Coder [Retrieving Elements Visible in View](https://thebuildingcoder.typepad.com/blog/2017/05/retrieving-elements-visible-in-view.html) and here [5.1. Custom Exporter](https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.1)

---

<div class="post-metadata">

**Author:** ![Filla96](https://avatars.discourse-cdn.com/v4/letter/f/da6949/32.png) [@Filla96](https://forum.dynamobim.com/u/Filla96)\
**Post date:** [October 9, 2023, 10:54am UTC](https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383/3 "2023-10-09T10:54:35Z")

</div>

@Mike.Buttery thank you for the response!

I’ve just realized my question wasn’t precise at all, sorry for that. In this case I’m trying to filter elements from the linked model in views from my current model (in my case these views will always exist both in the linked model and in the current model)

I do not have any rooms in my current model, only in the linked model, and I’m able to get those elements.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/4/f4cd2214265109b4fbca113ae62053dbb26ee8f2.png)

Considering that, is it possible to filter these elements within the crop view of the floor plans in my current model?

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [October 9, 2023, 1:22pm UTC](https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383/4 "2023-10-09T13:22:40Z")

</div>

Heya,

It is a tricky thing to explain 🙂

Your example is, as you say, retrieving link elements from a link doc using a link view. But you want a FEC using the link doc and the current doc view. That’s the problem. There is no way to use the current doc view for a link doc.

From memory, I got round this by constructing a solid using the extents of the link elements (as a bounding box would be axis aligned). Then I used a solid intersect to check whether the elements were inside.

I hope that helps,

Mark

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [October 9, 2023, 1:44pm UTC](https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383/5 "2023-10-09T13:44:10Z")

</div>

Hello,  
you can try with this example (assuming the cropbox is rectangular, if not, it is necessary to use solid intersection process as @Mark.Ackerley mentioned)

> [@Filter Element from Linked Model only if visible in active view](https://forum.dynamobim.com/t/filter-element-from-linked-model-only-if-visible-in-active-view/55039/6):
>
> Hello try this version #written by Cyril P import clr clr.AddReference('RevitAPI') import Autodesk from Autodesk.Revit.DB import \* clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager doc = DocumentManager.Instance.CurrentDBDocument lnkInstance = UnwrapElement(IN[0]) category = UnwrapElement(IN[1]) transf =lnkInstance.GetTotalTransform() actView = doc.ActiveView doclnk = lnkInstance.GetLinkDocu…

---

<div class="post-metadata">

**Author:** ![Filla96](https://avatars.discourse-cdn.com/v4/letter/f/da6949/32.png) [@Filla96](https://forum.dynamobim.com/u/Filla96)\
**Post date:** [October 9, 2023, 11:35pm UTC](https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383/6 "2023-10-09T23:35:46Z")

</div>

@c.poupin that worked perfectly.

Thank you all for the incredible fast responses and helpfullness!

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [October 10, 2023, 7:30am UTC](https://forum.dynamobim.com/t/filter-elements-in-view-within-the-crop-view/94383/7 "2023-10-10T07:30:41Z")

</div>

for information with Revit 2024+ if you have a linked view, you can use directly this method

> **[FilteredElementCollector Constructor (Document, ElementId, ElementId)](https://www.revitapidocs.com/2024/968b52a0-de55-2f96-de40-968812bc41c7.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018
