I am trying to create a Filled Region to calculate the area of a Beam System. I am able to extract the points from the Beam System sketch and create a series of new lines that are added to a curveloop that is than added to a list. I can see that lines are being drawn corrected in the 3D preview, but it gives me the following error:
Exception: An unexpected manged exception was thrown by internal Revit code.
I don’t know what the error is and can’t figure out where I went wrong. Can someone have a look and see if they see my error?
Below is the code I am using in the Python node:
dataEnteringNode = IN (a list of points is being fed in)
ptArray = IN
profiles = []
ptArray.Add(ptArray[0])
ptArraySize = len(ptArray)
length = ptArraySize-1
for i in range (0, length):
startPt = ptArray[i]
endPt = ptArray[i+1]
line = app.Create.NewLine(startPt, endPt, True)
profile = CurveArray()
profile.Append(line)
profiles.Add(profile)
collector = FilteredElementCollector(doc).OfClass(FilledRegionType)
filledRegionType = list(collector)[0]
regionId = filledRegionType.Id
viewId = doc.ActiveView.Id
fr = FilledRegion.Create(doc, regionId, viewId, profiles)