Switch join order - Blank line

Hi, I’m starting in python and I wanted to make a node to switch the join order.
However I got this message even if there is nothing in line 17

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 17, in
TypeError: expected Element, got List[object]

That’s the code that I used.

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from System.Collections.Generic import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

element1 = UnwrapElement(IN[0])
element2 = UnwrapElement(IN[1])

for x,y in zip (element1, element2):
	JoinGeometryUtils.SwitchJoinOrder(doc,x,y)

OUT = 0

Thank you in advance.

@JC.Moreno usually an error @ line 17 means line 16, I do not know why, but this is what I have learned over time dealing with python errors :slightly_smiling_face:; Moreover, I guess you need to use the transaction manager properly since you want to interact with Revit; Finally, and after correcting the transaction code, you can check that error, “if it remains” which is telling you that a Revit element is required while you are using an unknown object from a given list.

The problem is in your input, which we cannot see, since you didn’t post a picture of the Dynamo graph.

Your input should be for both IN[0] and IN[1] a flat list. Right now it is probably a Nested List.

You should also implement the Transaction manager. Since you are going to do stuff in Revit, you should start a transaction. Like @tradelie is also suggesting.

2 Likes

Thank you for your information.
Do you know where I could find some information on these transactions?

@JC.Moreno this one might be a good start:
https://primer.dynamobim.org/10_Custom-Nodes/10-6_Python-Templates.html
Just put your code within these 2 lines:

TransactionManager.Instance.EnsureInTransaction(doc)

TransactionManager.Instance.TransactionTaskDone()

Ahhh…ok! Yes you are right it works.
Thank you.

Thank you @tradelie. I’m going to take a look on that.

1 Like