Create Filled Region

def create_region(view, X, Y, region_width, region_height):
    # VARIABLES
    region_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.FilledRegionType)

    # REGION POINTS
    points_0 = XYZ(X, Y, 0.0)
    points_1 = XYZ(X+region_width, Y, 0.0)
    points_2 = XYZ(X+region_width, Y-region_height, 0.0)
    points_3 = XYZ(X, Y-region_height, 0.0)
    points = [points_0, points_1, points_2, points_3, points_0]

    # CREATE BOUNDARY
    list_boundary = List[CurveLoop]()
    boundary = CurveLoop()

    for n, point in enumerate(points):
        if n == 4: break
        # LINE POINTS
        p1, p2 = points[n], points[n + 1]
        # LINE
        boundary.Append(Line.CreateBound(p1, p2))
    list_boundary.Add(boundary)

    filled_region = FilledRegion.Create(doc, region_type_id, view.Id, list_boundary)
    return filled_region



doc   = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app   = __revit__.Application

active_view  = doc.ActiveView

# ARGUMENTS
region_type_id = doc.GetDefaultElementTypeId(ElementTypeGroup.FilledRegionType)

# POINTS
pt_0 = XYZ(50, 0, 0)
pt_1 = XYZ(55, 0, 0)
pt_2 = XYZ(55, 5, 0)
pt_3 = XYZ(50, 5, 0)

# LINES
l_0 = Line.CreateBound(pt_0, pt_1)
l_1 = Line.CreateBound(pt_1, pt_2)
l_2 = Line.CreateBound(pt_2, pt_3)
l_3 = Line.CreateBound(pt_3, pt_0)

# BOUNDARY
boundary = CurveLoop()
boundary.Append(l_0)
boundary.Append(l_1)
boundary.Append(l_2)
boundary.Append(l_3)

# LIST OF BOUNDARIES
list_boundaries = List[CurveLoop]()
list_boundaries.Add(boundary)

# CREATE FILLED REGION
region = FilledRegion.Create(doc, region_type_id, active_view.Id, list_boundaries)

⌨️ Happy Coding!
Erik Frits