Zone Hvac or system - Geometries

Hi,
I just want to extract line from zone. BoundingBox for zone do not exist in Dynamo. And a want the real perimeter of a non rectangle space.
In Revit lookup i can see BoundingBox and Geometry.
Is it possible in Python to have those information ?
It’s more difficult to extract global perimeter of very different form spaces.
Daniel OLIVÈS
Anse-France

1 Like

I find this in a topic
But a prefer extract Geometry, (BoundingBox are not correct)
Daniel OLIVÈS

<import clr
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(“RevitServices”)
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

def tolist(obj1):
if hasattr(obj1,“iter”): return obj1
else: return [obj1]

def GetBB(tblks,vws):
BBoxArr =
for tbs,vw in zip(tblks,vws):
bbox = tbs.get_BoundingBox(vw).ToProtoType()
BBoxArr.append(bbox)
return BBoxArr

TBlocks = tolist(UnwrapElement(IN[0]))
views = tolist(UnwrapElement(IN[1]))
OUT = GetBB(TBlocks,views)

Blockquote

you can use </> for copy/paste Code


 import clr
 clr.AddReference(‘RevitNodes’)
 import Revit
 clr.ImportExtensions(Revit.GeometryConversion)

 clr.AddReference(“RevitServices”)
 from RevitServices.Persistence import DocumentManager
 doc = DocumentManager.Instance.CurrentDBDocument

 def tolist(obj1):
 if hasattr(obj1,“iter”): return obj1
 else: return [obj1]

 def GetBB(tblks,vws):
 BBoxArr =
 for tbs,vw in zip(tblks,vws):
     bbox = tbs.get_BoundingBox(vw).ToProtoType()
     BBoxArr.append(bbox)
     return BBoxArr

 TBlocks = tolist(UnwrapElement(IN[0]))
 views = tolist(UnwrapElement(IN[1]))
 OUT = GetBB(TBlocks,views)

This should be what you need.

Hi,
Is’t ok for Zone HVAC but not for Zone-System
Daniel OLIVÈS

Can you try to better explain exactly what you’re after? Any relevant images would be helpful as well.

Hi Nick,
Here some png to explain differences.
With Zone HVAC lines are spaces lines and not only the peripherical line of the zone
z.Boundary give directely lines

With System Zone line are draw manually and they are in peripherical of the zone
line are in 3rd level Geometry, GeometryElement and lines

And the last, is what i try to do : 3 periphery lines for 3 SSi zones (Fire plan)
If i do that with region in color it need 3 plans, with only peripherical line with some offset
i draw only one plan.
Daniel OLIVÈS





Have you tried getting this info with Python? RevitLookup is wonderful for learning and applying the Revit API since it shows you exactly what the methods and properties look like and how everything is connected.

Hi,
I try to do that but with System-Zone i don’t find a solution to get line
Daniel OLIVÈS

PJ: Fire plan sample

You haven’t shown what you’ve tried though. How are you trying to get the boundary lines?

Is this what you’re expecting?

Solution with boundaries of spaces from Hvac Zone
same request here

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

	
def groupCurves(lstCurve, i = 0, max_iter = 10000):
	if len(lstCurve) > 0 and i < max_iter:
		loopCurve = [lstCurve.pop(0)]
		lst_idx = []
		while i < max_iter: 
			i += 1
			lenStart = len(lst_idx)
			for idx, c in enumerate(lstCurve):
				if any(c.DistanceTo(j) < 0.1 for j in loopCurve) and idx not in lst_idx:
					lst_idx.append(idx)
					loopCurve.append(c)
			if len(lst_idx) == lenStart:
				break

		otherCurves = [c for i, c in enumerate(lstCurve) if i not in lst_idx]
		return [DS.PolyCurve.ByJoinedCurves(loopCurve)] + groupCurves(otherCurves, i)
	else:
		return []

zone = UnwrapElement(IN[0])

optSpace = SpatialElementBoundaryOptions()
optSpace.SpatialElementBoundaryLocation  = SpatialElementBoundaryLocation.CoreCenter
surfacesSpace = []
for space in zone.Spaces:
	ArrArrSegments = space.GetBoundarySegments(optSpace)
	for segments in ArrArrSegments:
		proto_segments = [x.GetCurve().ToProtoType() for x in segments]
		polyCurve = DS.PolyCurve.ByJoinedCurves(proto_segments)
		surfacesSpace.append(polyCurve.Patch())

groupSurface = DS.Surface.ByUnion(surfacesSpace)
allcurves = groupCurves(list(groupSurface.PerimeterCurves()))

OUT = allcurves
3 Likes

@daniel82KGE I guess what you are looking for is a Generic Zone element boundary (GetBoundaries() Method):

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS


clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB


from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)


clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

zone = UnwrapElement(IN[0])

cLoop = zone.GetBoundaries()
		
OUT = [[revitLine.ToProtoType() for revitLine in loop] for loop in cLoop]

Hi Tradeli,
I get this error :
Avertissement:IronPythonEvaluator.EvaluateIronPythonScript l’opération a échoué.
Traceback (most recent call last):
File “”, line 31, in
AttributeError: ‘List[object]’ object has no attribute ‘GetBoundaries’

Daniel OLIVES

@daniel82KGE your input is one zone or a list of zones?

Hi,
My answer was not correct
My problem was i have use select all elements of category and not select model
I have a list of list if the script is correct
Thank’s for your help
Daniel OLIVÈS

1 Like

Hi,Tradelie
If i run the script a second time list is empty ?
Daniel OLIVÈS
Anse-Lyon

@daniel82KGE try to close Dynamo then re-run the script/ Use Dynamo Player/ Use Transaction.End

Hi tradelie,
When i close only Dynamo, same thing, when i close Revit and Dynamo
on 3 GenericZone only 1 have Line ??
I add before out
TransactionManager.Instance.TransactionTaskDone()

Daniel OLIVÈS

@daniel82KGE can you share a Revit sample file?

Hi,
a simple file with nothing in, else 3 GenericZones
Zones-System
Revit 2022 and Dynamo 2.12
Daniel