Creating Solid from area

I’m trying to generate solids from areas to check for items inside. I’m able to get the areas and their boundaries with GetBoundarySegments but I’m running into an issue when I try to create the CurveLoop. Is there any other way to create a solid from areas or a way to fix the boundaries in python so that we can use areas?

I’ve noticed that in Revit you can create an area in boundary lines that aren’t actually continuous. I think there is some margin of error so that people don’t need to be exact when creating area plans, which is nice but sucks for people like me that need those boundaries to create curveloops.

for a in areas:
    areasBoundaries.append(a.GetBoundarySegments(sEBO))
    #print(a.GetBoundarySegments(sEBO))
    print(a.LookupParameter("Name").AsString())
    ab = a.GetBoundarySegments(sEBO)
    curveLoop = CurveLoop()
    for l in ab:
        print(l)
        for c in l:
            print(c)
            curveLoop.Append(c.GetCurve())
    print(curveLoop)
    #curve = ab.GetCurve()
    solid = GeometryCreationUtilities.CreateExtrusionGeometry([curveLoop],XYZ.BasisZ,1)
    print(solid)
    areaSolids.append(solid)

It can get through a few area but then run into some sloppy boundaries and give this error:

Exception: This curve will make the loop discontinuous.
Parameter name: pCurve

Found the answer here: Area Boundary - Curves are not contiguous - #3 by danail.momchilov - Geometry - Dynamo

sEBO = SpatialElementBoundaryOptions()
sEBO.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center
1 Like