# Whats wrong in my collector?

**URL:** <https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904>\
**Category:** Revit\
**Created:** [July 18, 2023, 12:39pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904 "2023-07-18T12:39:40Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 18, 2023, 12:39pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/1 "2023-07-18T12:39:41Z")

</div>

Hello,

i want all my active elements in view (BCF view, allready elements isolated there)

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/c/dc8a91085e72a9b40d66a5cd9d1524109e717864.png)

here is my code

```auto
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

collector = FilteredElementCollector(doc,doc.ActiveView.Id).ToElements()

OUT = collector

```

KR

Andreas

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [July 18, 2023, 1:05pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/2 "2023-07-18T13:05:56Z")

</div>

Add `.WhereElementIsNotElementType().`

```auto
collector = FilteredElementCollector(doc,doc.ActiveView.Id).WhereElementIsNotElementType().ToElements()

```

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 18, 2023, 1:09pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/3 "2023-07-18T13:09:01Z")

</div>

> [@Alban\_de\_Chasteigner](#):
>
> `collector = FilteredElementCollector(doc,doc.ActiveView.Id).WhereElementIsNotElementType().ToElements()`

@Alban_de_Chasteigner

my view is the _BCF Manager 3D view_ … could that be the reason ?

it is still the same result! should i prefilter like show only 3D elements ?

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/a/4ac71764ff5ba80cce7038ed15c7408062c2e0e4.png)  
…thats actually weard stuff here ☹

KR

Andreas

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [July 18, 2023, 1:27pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/4 "2023-07-18T13:27:28Z")

</div>

hello, my hidden items are not collected like this

```auto
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

collector = FilteredElementCollector(doc,uidoc.ActiveView.Id).WhereElementIsNotElementType().ToElements()

OUT = collector

```

edit: sorry I was stupid, I didn’t save the python script between changes  
doc.Actiview.Id and uidoc.Actiview.Id , there is no change between these 2 states  
cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 18, 2023, 1:35pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/5 "2023-07-18T13:35:00Z")

</div>

@christian.stan ,

did also check with a “BCF-view” ?

…it still remains… for any reason it takes element that are not in the view, even with open/close dynamo

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/3/f324c1cf2114d76d8ff60f1455d2ea8c16a40942.png)

KR

Andreas

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [July 18, 2023, 2:31pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/7 "2023-07-18T14:31:28Z")

</div>

The other elements you’re seeing are `Cameras`, essentially view settings for other 3D views. You can filter them out with an `ElementCategoryFilter()` using the boolean overload. You could still have a few leftovers after that, depending on what all is in your view/project. You might also benefit from a `WhereElementIsViewIndependent()` filter as well.

> **[ElementCategoryFilter Constructor (BuiltInCategory, Boolean)](https://www.revitapidocs.com/2022/abd2686e-aa6b-c8b5-78d0-a7965451d287.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

This is why you have to be careful with true “all element” collectors. Just about everything in Revit is or has an element, often leaving you with a bunch of “extra” objects in your collector. The Dynamo node already filters out these extra categories.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 18, 2023, 2:59pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/8 "2023-07-18T14:59:22Z")

</div>

> [@Nick\_Boyts](#):
>
> `WhereElementIsViewIndependent()`

@Nick_Boyts ,

thanks! i become “creative” regarding your ideas, BUT…

look at my code:

```auto
import clr

import System
from System.Collections.Generic import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
builtInCat = List[BuiltInCategory]()

builtInCat.Add(BuiltInCategory.OST_Walls)
builtInCat.Add(BuiltInCategory.OST_Floors)
builtInCat.Add(BuiltInCategory.OST_Columns)
builtInCat.Add(BuiltInCategory.OST_Roofs)

Filter = ElementMulticategoryFilter(builtInCat)

collector = FilteredElementCollector(doc,doc.ActiveView.Id).WherePasses(Filter).ToElements()
#collector = FilteredElementCollector(doc,doc.ActiveView.Id).WhereElementIsViewIndependent().ToElements()
#collector = FilteredElementCollector(doc,doc.ActiveView.Id).WhereElementIsNotElementType().ToElements()
#WhereElementIsViewIndependent()
OUT = collector

```

how to implement this boolean like “if unknown” false…

i got this 😉

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/3/43e32d6d9cf3c6fac6c5d2dc6ab14974d8ef8faa.png)

is this a way, how can limit my view to the categories that might be in the view ?

KR

Andreas

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 18, 2023, 3:10pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/9 "2023-07-18T15:10:21Z")

</div>

```auto

Categories_ = doc.Settings.Categories

model_cat = []

for c in Categories_:
	if c.CategoryType == CategoryType.Model:
		model_cat.append(Revit.Elements.Category.ById(c.Id.IntegerValue))
	else: continue
	
OUT = model_cat

```

this code works also, but can i map it like “Categories\_.CurrentView”

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [July 18, 2023, 3:49pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/10 "2023-07-18T15:49:31Z")

</div>

Why are you wanting to filter out those elements? Isn’t that exactly what you want? You have roofs in your category filter and those elements are being included in the list. If you don’t want them just remove them from the filter.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 18, 2023, 3:52pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/11 "2023-07-18T15:52:39Z")

</div>

@Nick_Boyts ,

i know it for this view, but when i want it to use for other views, it could be also windows and curtiainwalls in the view…

so how can i set up my collector to all 3D Categories ? or is all “OST\_” 3D Categories ?

in the case for the Roofs it does not work, it is still “Unknown”. I think because they are InPlaceFamilies.

I came to this

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/5/95daa803582afc75e8e956607f559906e2109f89.png)

thats the code

```auto
import clr

import System
from System.Collections.Generic import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
builtInCat = List[BuiltInCategory]()

Categories_ = doc.Settings.Categories

model_cat = []

for c in Categories_:
	if c.CategoryType == CategoryType.Model:
		model_cat.append(Revit.Elements.Category.ById(c.Id.IntegerValue))
	else: continue
	
Categories_ = [x.Id for x in doc.Settings.Categories if x.CategoryType == CategoryType.Model]

catId = List[ElementId](Categories_)

Filter_ = ElementMulticategoryFilter(catId)

ModelElements = FilteredElementCollector(doc,doc.ActiveView.Id).WherePasses(Filter_).WhereElementIsNotElementType()
	
OUT = ModelElements

```

KR

Andreas

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [July 18, 2023, 4:07pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/12 "2023-07-18T16:07:53Z")

</div>

> [@Draxl\_Andreas](#):
>
> so how can i set up my collector to all 3D Categories ?

That’s where the `WhereElementIsViewIndependent()` filter comes in. View dependent elements are the elements specific to a view. View independent elements are the elements that exist in “model space” and are visible in all views (outside of filters and other view settings).

There are a handful of other view independent categories that are not model categories, but they don’t show up too often. It’s easier to filter them out rather than specify everything you want to include. This is where you can use the `ElementCategoryFilter()` with the boolean overload to _exclude_ `Camera` category elements (and any others you may have).

> [@Draxl\_Andreas](#):
>
> in the case for the Roofs it does not work, it is still “Unknown”.

The _object type_ is unknown, which is probably an issue with the wrapper, but you can see python is returning the element.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 18, 2023, 4:09pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/13 "2023-07-18T16:09:21Z")

</div>

> [@Nick\_Boyts](#):
>
> `WhereElementIsViewIndependent()`

@Nick_Boyts

it looks like this

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/b/6bf1d315142665992116c5c9dfa4abb3739a6fb9.png)

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/0/70e480eb439a9b286d4f6ff3cddbdc3f8fa7c399.png)

thats the ZeroTouch resulst

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

KR

Andreas

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [July 18, 2023, 4:19pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/14 "2023-07-18T16:19:28Z")

</div>

Correct, but you’re only filtering out one of the two issues you’re dealing with. That is only removing the objects that are view dependent. There should only be one by default. All the additional elements you’re seeing are the `Camera` elements from other 3D views. You have to filter out that category with an additional filter.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/e/0e3a64fba4523918a853c84757a60e7a4d1821cc.png)  
You need to include both filters:

```auto
collector = FilteredElementCollector(doc,doc.ActiveView.Id)
ecf = ElementCategoryFilter(BuiltInCategory.OST_Cameras, True)
filtered = collector.WhereElementIsViewIndependent().WherePasses(ecf).ToElements()

```

---

<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:** [July 18, 2023, 4:34pm UTC](https://forum.dynamobim.com/t/whats-wrong-in-my-collector/91904/15 "2023-07-18T16:34:53Z")

</div>

Hi,  
+1 for remove some extra categories

```auto

import clr
import System

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

builtInCat = List[BuiltInCategory]([BuiltInCategory.OST_Cameras, BuiltInCategory.OST_SectionBox])
not_filterCat = ElementMulticategoryFilter(builtInCat, True)

collector = FilteredElementCollector(doc,doc.ActiveView.Id).WherePasses(not_filterCat).ToElements()

OUT = collector

```
