Get beam system boundery line

Hi,

i try to get the boundary of the beam system in order to calculate the area.
no BI parameter for this on beam system class.
i try to get the curve geometry.
i get the lines but unfortunately cant convert them to dynamo by (ToProtoType())

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitAPIUI')
from  Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument

def tolist(obj1):
    if hasattr(obj1,'__iter__'): return obj1
    else: return [obj1]

grids=tolist(UnwrapElement(IN[0]))
Ref=[]

opt=Options()
opt.ComputeReferences=True
opt.IncludeNonVisibleObjects=True
opt.View=doc.ActiveView

for grid in grids:
	for obj in grid.get_Geometry(opt):
		if isinstance(obj, Line):
			gline = obj
			Ref.append(gline.ToProtoType())
OUT = Ref

image

Hi @amir.aroesti,

The ToProtoType() Method is an Extension Method. You first have to import the methode, before you can use it.

You do this by adding the RevitNodes DLL and import the extension methodes:

#Import the Revit Nodes
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

Then your code works perfectly :+1:

Thanks @Joelmick … so basic…

do you have any ideas on how to split between the are boundary line and the beam line itself?

Well yeah, if you look at the Beam System Class in the Revit API, the class has a Profile property. This property contains the boundary curves for the beam system.

https://www.revitapidocs.com/2022/fb63b4c6-1702-538c-01b8-ee622e3e9993.htm
You are now getting the whole geometry of the system, which also gives you the beam lines.

1 thing about your code. when I select multiple beam systems, I get one flat list as a result. I recommend you change this. return a list with sublists containing only the curves for that system.

Perfect. i thought the “Profile” property is exactly the opposite :slight_smile:

after using it the python code becomes much simple and not necessary to add more lists.

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference('RevitAPIUI')
from  Autodesk.Revit.UI import *

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

doc = DocumentManager.Instance.CurrentDBDocument

def tolist(obj1):
    if hasattr(obj1,'__iter__'): return obj1
    else: return [obj1]

sbs=tolist(UnwrapElement(IN[0]))

list = []
for bs in sbs:
	list.append(bs.Profile.ToProtoType())
OUT = list

Very good. But this will still return flat list :yum:

you can replace this

with

list = []
for bs in sbs:
    tempList = []
	tempList .append(bs.Profile.ToProtoType())
    list.append(tempList)
OUT = list
1 Like