# 'All Elements In View(s)' returning more elements then there are in the view

**URL:** <https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679>\
**Category:** Packages\
**Tags:** data-shapes\
**Created:** [July 11, 2023, 3:59pm UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679 "2023-07-11T15:59:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laura\_BIMChick](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Laura\_BIMChick](https://forum.dynamobim.com/u/Laura_BIMChick)\
**Post date:** [July 11, 2023, 3:59pm UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/1 "2023-07-11T15:59:28Z")

</div>

I have a multi-category schedule in my model, but it’s filtered a certain way to only show doors (through ‘parameter exists’ on a specific parameter that’s only added to the doors).

When I use the node ‘All Elements In View(s)’ (from Data-Shapes) on that schedule, there appear to be ‘stairs’ in my list… The schedule itself only contains 13 elements, the list in my script contains 18 elements… Even when I add ‘grand total count’ to the schedule it says 13…

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

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/a/0a6dea43372bc28b909bbb8e7c2826a8c054aee7.png)

Has anyone ever have this happen to them before?  
I can’t share the model because of copywright and privacy reasons and I don’t have time right now to recreate the same exact circumstances so I thought to already launch the question…  
I’ll try to recreate the circumstances tomorrow but if this is a glitch this might not be possible…

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 11, 2023, 4:45pm UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/2 "2023-07-11T16:45:44Z")

</div>

Without a data set to reproduce with one can only speculate, but can you select the stair elements themselves and confirm if they are the stair itself or if they are a portion thereof?

Schedules themselves have some unique filters which repress some objects from display, and the node might not be taking this into account. Testing in a more modern build might also be worthwhile.

The other option would be to select the objects in another way. Not sure how the Datashapes node works so check the guys there first, but implementing a filtered element collector on the schedule view should be pretty straightforward with Python, and that should limit what we see to match the schedule, barring some issues within the API itself.

---

<div class="post-metadata">

**Author:** ![pyXam](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/pyxam/32/163009_2.png) [@pyXam](https://forum.dynamobim.com/u/pyXam)\
**Post date:** [July 11, 2023, 11:31pm UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/3 "2023-07-11T23:31:17Z")

</div>

You might need to filter off the sub-components from the list coming in here, similar to below.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/6/4619ae8ef4849eadbaf4990716c6d46a9197b96d.png)

But if this isn’t it, then try making a 3d view with all components in your model visible, make it the only view you have open, and click the green numbers next to your “Stairs”

Might help you find what / where they are to determine what solutions could be used.

---

<div class="post-metadata">

**Author:** ![Laura\_BIMChick](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Laura\_BIMChick](https://forum.dynamobim.com/u/Laura_BIMChick)\
**Post date:** [July 12, 2023, 6:37am UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/4 "2023-07-12T06:37:27Z")

</div>

To answer the first question and also @pyXam 's question, the stair elements are actual stairs, not subcomponents.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/1/51c5efe84d3e3c9a683b842156e4481725a1c5cd.png)

Unfortunately I have not found the time to dabble in writing my own Python code. If you know about a really good beginners course for Python 101, I would be happy to take a look since it has been on my list for a while…

In the meantime, if anyone else knows more about a filtered element collector (for the schedule view) in Python, let me know!

I’m working on recreating the problem in an empty revit file, will update later today!

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 12, 2023, 7:10am UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/5 "2023-07-12T07:10:52Z")

</div>

> [@Laura\_BIMChick](#):
>
> In the meantime, if anyone else knows more about a filtered element collector (for the schedule view) in Python, let me know!

I think if you stop this code at line 36 you should get the result you want.

> <https://github.com/Amoursol/dynamoPython/blob/0de1c37a52b507a19504112d4beae1fce5687528/revitAPI/filteredElementCollectorAllFamilyInstancesOfCategoryInActiveView.py#L36>

That it shows the container stair is interesting. Any chance that it contains one of the elements in the schedule?

---

<div class="post-metadata">

**Author:** ![Laura\_BIMChick](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Laura\_BIMChick](https://forum.dynamobim.com/u/Laura_BIMChick)\
**Post date:** [July 12, 2023, 7:14am UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/6 "2023-07-12T07:14:34Z")

</div>

@jacob.small Okay, so I was able to recreate the exact circumstances from my model.  
I copied the visible elements (doors) that were in my schedule, as well as selected the stairs by ID and copied them as well, all to an empty project.  
I also transferred the schedule I’m using for the script.

I also have the script to select the schedule elements, and again the stair elements appear in the list…

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/2/52294b69179fdfb92298fa78616c9dfb981dd04b.png)

Script:  
[All elements in (schedule) view.dyn](https://forum.dynamobim.com/uploads/short-url/j2dWdsgqIBs3pHhjCHKE9nxyVeg.dyn) (4.5 KB)  
Revit File:  
[Select all elements in schedule view, showing stairs.rvt](https://forum.dynamobim.com/uploads/short-url/4upjfAaE8xgy5GB1hmBMTP758hV.rvt) (6.0 MB)

---

<div class="post-metadata">

**Author:** ![Laura\_BIMChick](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Laura\_BIMChick](https://forum.dynamobim.com/u/Laura_BIMChick)\
**Post date:** [July 12, 2023, 7:30am UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/8 "2023-07-12T07:30:06Z")

</div>

I’m still getting the 18 elements, so including the stairs…

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

---

<div class="post-metadata">

**Author:** ![pyXam](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/pyxam/32/163009_2.png) [@pyXam](https://forum.dynamobim.com/u/pyXam)\
**Post date:** [July 21, 2023, 3:53am UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/9 "2023-07-21T03:53:41Z")

</div>

Hi Laura,

I tried working on this for as long as i had today, admittedly not long but still…  
I After working at it from a few angles, it doesn’t appear that this is a super nice solution.

prettymuch the angle i would take would be to apply the same filters to the collection of the elements as you have in the schedule.

Whilst i don’t think this was the intent of how this workflow would work, it does at least work.

---

<div class="post-metadata">

**Author:** ![Laura\_BIMChick](https://avatars.discourse-cdn.com/v4/letter/l/bbce88/32.png) [@Laura\_BIMChick](https://forum.dynamobim.com/u/Laura_BIMChick)\
**Post date:** [August 3, 2023, 9:49am UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/10 "2023-08-03T09:49:25Z")

</div>

Hi @pyXam, this is indeed not what I’m looking for in this workflow and I think too extensive for what I need it for…

---

<div class="post-metadata">

**Author:** ![Mostafa\_El\_Ayoubi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mostafa_el_ayoubi/32/7815_2.png) [@Mostafa\_El\_Ayoubi](https://forum.dynamobim.com/u/Mostafa_El_Ayoubi)\
**Post date:** [August 3, 2023, 11:33am UTC](https://forum.dynamobim.com/t/all-elements-in-view-s-returning-more-elements-then-there-are-in-the-view/91679/11 "2023-08-03T11:33:31Z")

</div>

Hi @Laura_BIMChick  
It’s funny I’ve had a similar issue not so long ago.  
This node uses what @jacob.small was pointing at in an earlier response : FilteredElementCollector(doc,view.Id) . This method doesn’t seem to play well with schedules that have filters - that was my conclusion after a couple of experiments… So here’s a different approach that is specific to schedules, and that implements a logic I found on the [Revit forum](https://forums.autodesk.com/t5/revit-api-forum/quick-way-of-counting-rows-in-a-schedule/m-p/8497051/highlight/true#M35913)🙂

```auto
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

if isinstance(IN[0],list):
	views = UnwrapElement(IN[0])
else:
	views = [UnwrapElement(IN[0])]
itemInScheduleRowId = []
for v in views:
	#Listing items found by collector method
	initialList = FilteredElementCollector(doc, v.Id).ToElementIds()
	#Getting info to be able to iterate through table rows
	table_data = v.GetTableData()
	section_data = table_data.GetSectionData(SectionType.Body)	
	no_of_rows = section_data.NumberOfRows	
	#iterating through rows...
	for i in range(no_of_rows):
		#we create subtransactions to temporary delete row and then rollback
		TransactionManager.Instance.EnsureInTransaction(doc)
		st = SubTransaction(doc)
		st.Start()		
		# Use Try/Except to handle any rows that can't be removed
		try:
			section_data.RemoveRow(i)
			#After deleting, we reuse the collector method to check the difference
			remaining = FilteredElementCollector(doc, v.Id).ToElementIds()
			remaining = list(remaining)
			#deducing the element Id of the row by comparison
			deleted = [i for i in initialList if i not in remaining]
			itemInScheduleRowId.extend(deleted)  			
			st.RollBack()			
		except:
			st.RollBack()
			
		TransactionManager.Instance.ForceCloseTransaction()

OUT = [doc.GetElement(i) for i in itemInScheduleRowId]

```

I’ve pushed an udpate to the All Elements In View(s) in version 2023.2.110 of the package so it detects and handles schedule views better (including cases where all instances aren’t itemized).
