In revit 2023, The Api of NewFloor.Create(), change To DB.Floor.Create().
when i using pyrevit and python3 script always raise error as
ArgumentException : The input curve loops cannot compose a valid boundary, that means: the “curveLoops” collection is empty; or some curve loops intersect with each other; or each curve loop is not closed individually; or each curve loop is not planar; or each curve loop is not in a plane parallel to the horizontal(XY) plane; or input curves contain at least one helical curve.
#! python3
from System.Collections.Generic import List
from Autodesk.Revit import DB
# Test.py
doc = __revit__.ActiveUIDocument.Document
def transaction(func):
def wrapper(*args, **kwargs):
t = DB.Transaction(doc, 'Create Elements')
t.Start()
func(*args, **kwargs)
t.Commit()
return wrapper
@transaction
def main():
level_data = {level.Elevation: level for level in DB.FilteredElementCollector(doc).OfClass(DB.Level)}
level = level_data[list(level_data.keys())[0]]
default_floor_type = DB.Floor.GetDefaultFloorType(doc, False)
p1 = DB.XYZ(0, 0, 0)
p2 = DB.XYZ(20, 0, 0)
p3 = DB.XYZ(20, 15, 0)
p4 = DB.XYZ(0, 15, 0)
cloop = DB.CurveLoop()
cloop.Append(DB.Line.CreateBound(p1, p2))
cloop.Append(DB.Line.CreateBound(p2, p3))
cloop.Append(DB.Line.CreateBound(p3, p4))
cloop.Append(DB.Line.CreateBound(p4, p1))
# if i use the [cloop] / cloop, not the List[DB.CurveLoop](cloop)
# it will raise typeerror : No method matches given arguments for Create: (<class 'Autodesk.Revit.DB.Document'>, <class 'list'>, <class 'Autodesk.Revit.DB.ElementId'>, <class 'Autodesk.Revit.DB.ElementId'>)
DB.Floor.Create(doc, List[DB.CurveLoop](cloop), default_floor_type, level.Id)
main()
If i use BoundaryValidation.IsValidHorizontalBoundary() method to check the curveloop, it will return False.
someone can fix this problem ?