Finding the view a Filled Region is in

Here’s what i’m doing right now?

I looked for all Detail Items that i filter by “Filled Region”. I then get the worksets from that items.

I look for all worksets in the project then filter them using the name (looking for “Floor Plans” right now). From that shorter list i retrieve the Name.

I then compare the 2 list to get the View.

It’s extremely slow (number of elements are huge), so i’m open to any other suggestions to make it faster :slight_smile:
Thanks

I also just notice that Filled and Masking Region are the same when using Detail Items to select. Any ways to differentiate them?

Hi @Daniel_Hurtubise ,

here’s one way to get all filed regions (and no masking region) and the view they belong to :

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
import System
doc = DocumentManager.Instance.CurrentDBDocument
collector = FilteredElementCollector(doc).OfClass(FilledRegion)

regions = [i for i in collector if i.IsValidFilledRegionTypeId(doc,i.GetTypeId())]
views = [doc.GetElement(r.OwnerViewId) for r in regions]
OUT = regions , views
6 Likes

Actually i found out that masking don’t have Family and Type so i can filter them using that… no python :wink:

Thanks guys

1 Like

Hi @Mostafa_El_Ayoubi if I want to get the type of filled region then which method should I use?? I am trying with the below code using the post you pasted above.

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
import System
doc = DocumentManager.Instance.CurrentDBDocument
collector = FilteredElementCollector(doc).OfClass(FilledRegion)

regions = [i for i in collector if i.IsValidFilledRegionTypeId(doc,i.GetTypeId())]
type = regions.GetType
views = [doc.GetElement(r.OwnerViewId) for r in regions]
OUT = regions , views , type