Create Pipes and List Pipes Python

Hey everyone.
I have created a code that that creates pipes using Inputs: Line, PipeType, SystemType, Level and Diamater of pipe (in that order).

The code works in terms of creating the pipes, however as OUT it only lists null values. and not the pipes and i can not figure out why. ChatGPD did not work either.

Maybe somebody can help

Code:
import clr
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

if isinstance(IN[0], list):
lines = IN[0]
else:
lines = [IN[0]]
FirstPoint = [x.StartPoint for x in lines]
SecondPoint = [x.EndPoint for x in lines]
if isinstance(IN[1], list):
pipetype = UnwrapElement(IN[1])
else:
pipetype = [UnwrapElement(IN[1])]
ptl = len(pipetype)

if isinstance(IN[2], list):
systemtype = UnwrapElement(IN[2])
else:
systemtype = [UnwrapElement(IN[2])]
stl = len(systemtype)
if isinstance(IN[3], list):
level = UnwrapElement(IN[3])
else:
level = [UnwrapElement(IN[3])]
ll = len(level)
if isinstance(IN[4], list):
diameter = IN[4]
else:
diameter = [IN[4]]
dl = len(diameter)

elements =

TransactionManager.Instance.EnsureInTransaction(doc)
for i, x in enumerate(FirstPoint):
try:
levelid = level[i % ll].Id
systypeid = systemtype[i % stl].Id
pipetypeid = pipetype[i % ptl].Id
diam = diameter[i % dl]

    pipe = Autodesk.Revit.DB.Plumbing.Pipe.Create(doc, systypeid, pipetypeid, levelid, x.ToXyz(), SecondPoint[i].ToXyz())

    param = pipe.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM)
    param.SetValueString(diam.ToString())

    elements.append(pipe.ToDSType(False))
except:
    elements.append(None)

TransactionManager.Instance.TransactionTaskDone()

OUT = elements # Output the list of all pipes created

Hi @hannah.salzgeber_you you could look at mepover nodes and see how it can be done