Pipe connection and transaction

Hi,
I’m trying to achieve below.

  1. Reduce pipe length to align
  2. Connect elbow fitting to open pipe end

I have tried doing both steps in a for loop inside a transaction in a Python node. I have also tried doing both separately in two Python nodes and supplying the output resized pipes from step 1 python node to step 2 node.

Still, the problem is the first pipe of the input list stays disconnected physically. It is probably because Revit API is still reading its “old” open connecter or there is only one transaction in Revit by Dynamo? Please suggest.