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

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

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…

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.

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

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.

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

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!

1 Like

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

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

@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…

Script:
All elements in (schedule) view.dyn (4.5 KB)
Revit File:
Select all elements in schedule view, showing stairs.rvt (6.0 MB)

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

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.

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…

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 :slight_smile:

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).

6 Likes