I’m trying to generate siteSubregion through Python. In fact, I can already do this with the help of the code provided by PowellDesign.
In the code he provided, every time curveLoop generates a new Subregion. But what I expect is to make multiple sets of curveLoop generate a single Subragion.
The following is my attempt to modify the code provided by PowellDesign, and I swear it succeeded several times based on the same data! But in most cases it is paralyzed. I don’t know what went wrong.
SiteSubRegion.Create(doc, List[CurveLoop](curveloops), host.Id)
I seem to have found a key factor that caused the “SiteSubRegion Method” to fail. This method does not seem to allow the specified “curveloop” to intersect. When I try to offset all Polygons inward by 0.01 meters and delete the Polygons that have self-intersections, everything works fine.
I don’t know if I solved the problem correctly, but everything looks good from the current results. Thank you for your reply!
I’m posting the final code here, with a slight modification, for reference and in case somebody needs it someday.
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *
from System.Collections.Generic import List
from RevitServices.Transactions import TransactionManager
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
# Get input variables
subregions = UnwrapElement(IN)
host = UnwrapElement(IN)
# Init variables
curveLoops = 
createdSubRegions = 
# Get groups of curves (exploded polycurves!) and creates per group a SubRegion
for i in L2:
# Init CurveLoop for every curve group
x = CurveLoop()
# Iterate the seperate curves -> convert type to Revit Type -> add to CurveLoop
for j in i:
# Create SubRegion out of the CurveLoop group and add its to 'createdSubregions'
newSubRegion = SiteSubRegion.Create(doc, curveLoops, host.Id)
newList = 
OUT = newList
OUT = "set IN to True to run"
the output does not work with multiple sublist of curves, it shows only the first, although it creates many subregions as the given curve list group