Filter Element from Linked Model only if visible in active view

Hi all,

I need some help. I’m trying to reduce the range of the action of a script, focusing only on a portion of the project, in order to reduce the runtime.

I really would like to filter all the elements (already filtered by category and contained in a linked file) that are visible in the active view. I already saw and read lots of similar post but none of the solution founded seems to work.

those 3 cable trays are visible… why I don’t have 3 true value in the Elements.IsVisible block??

can’t even find te package of Get Revit.Activeview or Revit Active.view nodes…

I really appreciate some help

Many thanks

1 Like

test.dyn (7.8 KB) Hope it will help you…


currently Revit API does not allow this (get link elements from active view)
a workaround is possible with a search for LinkElements by boudingBox or SolidIntersection (CropBox and ViewRange from HostView) without taking into account the different filters that there may be in the view or view template
you can try this node from Data-Shapes
getlinkElements dataShape

1 Like

elements I need are in linked files. In this case this node seems not working…

I also tried this way… can’t understand why I have null as a result…

try this version

#written by Cyril P
import clr
import Autodesk
from Autodesk.Revit.DB import *

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
1 Like

this is great! but if I understood well… it works only with plan views… not with 3D view…
I would have to run the script floor by floor… or does it takes the volume of the section box?

For 3D views, you can use the SelectByCategoryAndHost3DView node.


which is its package? “Genius Loci” ?


Could it be possible that it doesn’t work if you run this node in a central cloud model with different workset?
If I run it in a deattached model everything is fine without workset…
if I run it in a cloud central model, the filter of elements doesn’t work properly…

It is working fine with models with worksets:

Some nodes could be disturbed but I don’t currently have a cloud project and therefore can’t verify that it is working properly.
How do you select the linked document ? Can you show a screenshot with previews enabled under the nodes ?

@c.poupin the script is not selecting keynote tags! Is there any possible way to do that?

The script is not compatible with IndependentTag, a workaround will be to collect the physical elements of the linked model (via the script above) then to find the keynote tags attached to them.

as a reminder the script is already a workaround because currently Revit API does not allow get link elements from active view

1 Like

Thank you! Will try as you suggested!

1 Like