How do fix this error when use Python Script Create Rebarfromcurves? Exception: curves do not form a valid CurveLoop

import clr
import System
from System.Collections.Generic import *
from System.Collections.Generic import IList,List

clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import*
from Autodesk.Revit.DB.Structure import *
from Autodesk.Revit.Exceptions import ArgumentException

clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import *

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

doc = DocumentManager.Instance.CurrentDBDocument
rebarstyle = RebarStyle.Standard
rebartype = UnwrapElement(IN[0])
startHookOrient = UnwrapElement(IN[1])
endhookOrient = UnwrapElement(IN[2])
hostelement = UnwrapElement(IN[3])
norm = XYZ(0,0,1)
curves=List[Curve]([c.ToRevitType(True) for c in IN[4]])
OUT = []
TransactionManager.Instance.EnsureInTransaction(doc)
try:
	rebar = Rebar.CreateFromCurves(doc,rebarstyle,rebartype,startHookOrient,endhookOrient,hostelement,norm,curves,RebarHookOrientation.Left,RebarHookOrientation.Right,True,False)
except ArgumentException:
	OUT.append(None)
TransactionManager.Instance.TransactionTaskDone()

Do you mind sharing relevant files? It will help others who’s trying to help you.

2 Likes

Sorry for the inconvenience…This is my file… Thank you

Rebar from Cad.dyn (19.6 KB)

Revit File: