I’m upgrading a script from R22 to R24 and i’m getting some unexpected behavior. The script creates floors from polycurves. I implement some structure to account for holes, so not using OOTB Dynamo nodes.
R24
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import System.Collections.Generic
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
from RevitServices.Transactions import TransactionManager
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
floorType = ElementId(IN[2])
levelId = ElementId(IN[0])
regions = IN[1]
fRegions = []
trace = []
#outer = boundaries.pop(0)
#inner = boundaries
result = []
for bdy in regions:
# outer loop is first and counterclockwise
# holes are the rest and clockwise
trace.append("region found")
rtrace = []
rtrace.append(" initialize boundary")
boundariesLoop = List[CurveLoop]()
for b in bdy:
subtrace = []
try:
subtrace.append(" found curve as a "+str(type(b)))
boundariesLoop.Add(b.ToRevitType())
subtrace.append(" added as a "+str(type(b.ToRevitType())))
except Exception as e:
subtrace.append(e)
rtrace.append(subtrace)
rtrace.append(" boundaries as "+str(type(boundariesLoop)))
rtrace.append(boundariesLoop)
try:
TransactionManager.Instance.EnsureInTransaction(doc)
floor = Floor.Create(doc, boundariesLoop, floorType, levelId)
TransactionManager.Instance.TransactionTaskDone()
result.append(floor)
except Exception as e:
rtrace.append(e)
trace.append(rtrace)
OUT = result,trace
What might cause these two different outcomes from the same code? What is odd to me is that the knots issue isn’t raised in R2022 with the same geometry. I added some traces and it looks like it has more to do with the x.ToRevitType() method failing to convert the curves
[
[
Empty List,
[
region found,
[
initialize boundary,
[
found curve as a <type 'PolyCurve'>,
The multiplicities of other interior knots must be at most degree - 2.
Parameter name: knots
],
boundaries as <type 'List[CurveLoop]'>,
Empty List,
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.
Parameter name: profile
],
region found,
[
initialize boundary,
[
found curve as a <type 'PolyCurve'>,
The multiplicities of other interior knots must be at most degree - 2.
Parameter name: knots
],
boundaries as <type 'List[CurveLoop]'>,
Empty List,
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.
Parameter name: profile
],
region found,
[
initialize boundary,
[
found curve as a <type 'PolyCurve'>,
The multiplicities of other interior knots must be at most degree - 2.
Parameter name: knots
],
boundaries as <type 'List[CurveLoop]'>,
Empty List,
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.
Parameter name: profile
],
region found,
[
initialize boundary,
[
found curve as a <type 'PolyCurve'>,
The multiplicities of other interior knots must be at most degree - 2.
Parameter name: knots
],
boundaries as <type 'List[CurveLoop]'>,
Empty List,
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.
Parameter name: profile
]
]
]
]