Python Lists - Expected Element got List

I am attempting my second python node and have just spent about an hour searching for some kind of answer, but I am stumped. I will have a list of elements with pre-defined joins: 1 floor element and 1 wall element per join.

I want to cycle through each pair of joins in the list and change the join order.

Not sure what I am doing wrong. :frowning:

doc = DocumentManager.Instance.CurrentDBDocument

floors = [0]
walls = [1]

for floor,wall in zip (floors, walls):

OUT = 'join orders are changed.'

Current error is “Expected Element, got list”

Thank you in advance!

Do you mean to use the list of floors and walls here, or the floor and and wall in the list?

1 Like

search the forum database. search term " got list"


doc = DocumentManager.Instance.CurrentDBDocument

floors = UnwrapElement(IN[0])
walls = UnwrapElement(IN[1])

for floor,wall in zip (floors, walls):

OUT = 'join orders are changed.'

Remove the “s” to the floor and the wall in SwitchJoinOrder to act on the element and not on the list of elements.
It’s strange that you don’t unwrap your inputs.


Hi Alban,

I will test your code later tonight.

I understand what wrapping elements does in principle, but I don’t know when or why to apply it.

I am only just starting along a very long and bumpy path to understand scripting with python. :confused:


Hi Alban,

I tried your code, and now I have a new error that my floors “are not iterable.”


I did a quick search to try and find a similar issue, but I am starting to lose patience.

I’m not asking for you to simply feed me answers, but I’ve spent at least 2-3 hours trying to get a wall and a floor to change join orders.

This means that your floors input is not a list but a single item.
Add a List.Create node to your floor.

Now I finally understand why editable custom nodes create lists and immediately flatten them before feeding the python script!

It worked!!!

Thank you very much!

So I tested the script in a file with a couple of elements, and it worked wonderfully.

Once I wanted to use it in a project, I received a transaction error and an exception.

First question, if I may ask; how do you handle exceptions. (In this case, I would like to skip over, or remove them from my list. I guess this is done with “try”?

And secondly, why did I need a transaction manager in my project when it had already worked previously? Or rather, how do I know when I should use a transaction manager?

And finally, transactions show up in the “undo” of my revit project. I assume if I run a dynamo script with a python node which contains a transaction, the script will create two transactions in my project. Is that also correct?