Create.NewFloor retruns Error curves do not form a closed loop

Hello,

Goal
what I was trying to do is a floor via revit API but returns with an error :cry:

Backgorund
it is dynamo 2.0 in Revit 2019 no third pakages…

error
““Exception: The curves do not form a closed contiguous loop.
Parameter name: curves””

workflow
create 4 point > create 4 lines (to create a rectangle) > call Create.NewFloor (in the first argument, I have converted the revitgeometry )

could you please support me :slight_smile: or pointing to the correct documentation

Thank you

floors.dyn (33.6 KB)

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *


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


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

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

# The inputs to this node will be stored as a list in the IN variables.
doc = DocumentManager.Instance.CurrentDBDocument

crv = IN[0]
floortype = IN[1]
lvl = IN[2]
bol = IN[3]
cArr =CurveArray()

for i in crv:
	cArr.Append(i.ToRevitType())
	
TransactionManager.Instance.EnsureInTransaction(doc)

newflroor = doc.Create.NewFloor(cArr,floortype,lvl,bol)
out = newflroor.ToDSType(True)

TransactionManager.Instance.TransactionTaskDone()

# Place your code below this line

# Assign your output to the OUT variable.
OUT = 0

Hello and welcome :slightly_smiling_face:
A solution making a polycurve first


# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *


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


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

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

# The inputs to this node will be stored as a list in the IN variables.
doc = DocumentManager.Instance.CurrentDBDocument

crv = PolyCurve.ByJoinedCurves(IN[0])
floortype = IN[1]
lvl = IN[2]
bol = IN[3]
cArr = CurveArray()

for i in crv.Curves():
	cArr.Append(i.ToRevitType())
	
TransactionManager.Instance.EnsureInTransaction(doc)

newflroor = doc.Create.NewFloor(cArr,floortype,lvl,bol)
out = newflroor.ToDSType(True)

TransactionManager.Instance.TransactionTaskDone()

# Place your code below this line

# Assign your output to the OUT variable.
OUT = out
1 Like

Thank you… for that :slight_smile: I would like to ask you where and how did you find it?

Semantically speaking, that means that a list of the concatenated curves doesn’t mean a polycure… Well, good to know, thank you!!!

@g.claudio.scarafini
Creation.Document.NewFloor() method need consecutive curves (with the same direction)
PolyCurve.ByJoinedCurves() and polycurve.Curves() methods are perfect for this case

1 Like