List[Element] object has no attribute 'pop'

Good day all,
I’m working on a script that obtains two lists of elements (FireAlarmDevices and GenericAnnotations) via a FilteredElementCollector and after performing some processing in a for loop, I wish to remove the element that I’ve just process from the list.

My first response was to just do FAElements.pop(FAElements.index(element)), but I got an error that “List[Element] object has no attribute ‘pop’”. So then tried del FAElements[FAElements.index(FAann)] and FAElements.remove(FAElements.index(element)) with similar results.

Is there a way to perform a “pop” or something similar for a list of elements?


The List[Element] type is from the .net framework. If you want to use a python list when you get elements using a FilteredElementCollector you need to wrap it with a list first.

Here’s a demonstration using RevitPythonShell

>>> elements = FilteredElementCollector(doc).OfClass(FamilyInstance).ToElements()
>>> type(elements)
<type 'List[Element]'>
>>> elements = list(FilteredElementCollector(doc).OfClass(FamilyInstance))
>>> type(elements)
<type 'list'>
1 Like

You want List.RemoveAt() for a .Net iList.
There is also List.Remove(), ListSlice() and List.RemoveRange()

IList.RemoveAt(Int32) Method (System.Collections) | Microsoft Learn