The script doesnāt check if the boundaries are on the surface of the topography. Just a quick and dirty try to solve the problem. The first input are the curves (not the polycurve, create out of the polycurves again curves) and the second one is the topography you want the subregions on.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture 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
# Get input variables
subregions = IN[0]
host = UnwrapElement(IN[1])
# Init variables
curveLoops = []
createdSubRegions = []
error = []
TransactionManager.Instance.EnsureInTransaction(doc)
# Get groups of curves (exploded polycurves!) and creates per group a SubRegion
for i in subregions:
# Init CurveLoop for every curve group
x = CurveLoop()
# Iterate the seperate curves -> convert type to Revit Type -> add to CurveLoop
for j in i:
x.Append(j.ToRevitType())
curveLoops.append(x)
# Add layer to list
y = [x]
yI = List[CurveLoop](y)
if SiteSubRegion.IsValidBoundary(yI):
# Create SubRegion out of the CurveLoop group and add its to 'createdSubregions'
newSubRegion = SiteSubRegion.Create(doc, yI, host.Id)
createdSubRegions.append(newSubRegion)
TransactionManager.Instance.TransactionTaskDone()
# Output
OUT = createdSubRegions
if SiteSubRegion.IsValidBoundary(yI):
# Create SubRegion out of the CurveLoop group and add its to 'createdSubregions'
newSubRegion = SiteSubRegion.Create(doc, yI, host.Id)
createdSubRegions.append(newSubRegion.TopographySurface)
TransactionManager.Instance.TransactionTaskDone()
# Output
OUT = createdSubRegions
That should output the associated topo for each sub region
Hi All,
really interesting this post, thanks for the great Python code.
my workflow is slightly different from the previous explained here and the python doesnāt work in my case.
I try to explain:
I use a linked toposurface created in Civil3D linked trough BIM360.
When inside revit you draw a subregion inside a linked toposuface, for some reason unknown to me, the subregion becomes like a normal subregion created from a native revit topography.
this new subregion can be used without problem with Dynamo to create other elements, like floor.
Because I have a lot of subregion to create before use them to create floors, Iād like to create this subregion with dynamo instead of manually.
Iāve tried to use this python to do this but i receive an error when I use it with linked toposurface, as show in the following images.
my knowledge of python is limited and I donāt know if it is possible fix the problem.
Great post!
Can i create a single subregion with āholesā like a street with a median strip between lanes?
I tried editing the code but i dont know how to put 2 loops in one subregion.
Hi, really interesting script! Thank you. I wanna ask if it is possible to modify the script and avoid the creation of ānestedā subregion. I attach images of the expected result, which i have obtained manually. I want to do it in dynamo, because i will have hundreds of those subregions.
Good afternoon Jacob,
Iām trying to create multiple subregions from Autocad drawings with multiple closed polylines. But I keep getting the āā¦more than one wireā error. What am i doing wrong?
This error is pretty self explanatory - effectively your sublists of lines are branching or are part of multiple loops. That is to say they are shaped like a Y or all curves in a given sub-list donāt form a single closed loop but multiple.
First confirm there are no overlapping or doubling back lines by looking closely at the data labels in your geometry preview. If there are multiple indicies listed in what looks like it should be one line you may have to clean up your source data.
Next confirm there are no ādonutā shapes with holes in the middle. If this is the case the node āGroup Curvesā will help resolve the values, but there may be unavoidable errors when creating the subregions.
If these tips donāt straighten you out please start a new thread and provide a simplified version of your source data (the dwg with unnecessary info purged out and cleaned, and an rvt with the link and minimal associated elements in it).