# Filter Element from Linked Model only if visible in active view

**URL:** <https://forum.dynamobim.com/t/filter-element-from-linked-model-only-if-visible-in-active-view/55039>\
**Category:** Revit\
**Created:** [September 10, 2020, 9:41pm UTC](https://forum.dynamobim.com/t/filter-element-from-linked-model-only-if-visible-in-active-view/55039 "2020-09-10T21:41:12Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [September 14, 2020, 7:45am UTC](https://forum.dynamobim.com/t/filter-element-from-linked-model-only-if-visible-in-active-view/55039/6 "2020-09-14T07:45:51Z")

</div>

Hello  
try this version

 ![select link Elements in Active view](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/4/a45109373f139967634d5085a16a02a4a1e04316.png)

```
#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.GetLinkDocument()
#get bootom and top Elevation of active viewrange 
viewRange = actView.GetViewRange()
topClipPlaneId = viewRange.GetLevelId(PlanViewPlane.TopClipPlane) 
topClipPlane = doc.GetElement(topClipPlaneId)
topOffset = viewRange.GetOffset(PlanViewPlane.TopClipPlane)

bttmClipPlaneId = viewRange.GetLevelId(PlanViewPlane.BottomClipPlane) 
bttmClipPlane = doc.GetElement(bttmClipPlaneId)
bttmOffset = viewRange.GetOffset(PlanViewPlane.BottomClipPlane)

bbxActView = actView.CropBox 
#set min and max from active ViewRange
bbxActView.Min = XYZ(bbxActView.Min.X, bbxActView.Min.Y, bttmClipPlane.Elevation + bttmOffset)
bbxActView.Max = XYZ(bbxActView.Max.X, bbxActView.Max.Y, topClipPlane.Elevation + topOffset)
bbxActView.Transform = transf

myOutLn = Outline(bbxActView.Min, bbxActView.Max)   
#create LogicalOrFilter with BoundingBox 
filterBbxInside = BoundingBoxIsInsideFilter(myOutLn)
filterBbxInters = BoundingBoxIntersectsFilter(myOutLn)
filterBbx = LogicalOrFilter(filterBbxInside, filterBbxInters)
#make collector
fecActiveView = FilteredElementCollector(doclnk).OfCategoryId(category.Id).WherePasses(filterBbx).ToElements()

OUT = fecActiveView
```

---

_[View the full topic](https://forum.dynamobim.com/t/filter-element-from-linked-model-only-if-visible-in-active-view/55039)._
