Edge Length by Line Style from Filled Region

Hi @endison8,
Welcome to the Dynamo community.
This should give you all the information that you require

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

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

region = tolist(UnwrapElement(IN[0]))
geoOpt = app.Create.NewGeometryOptions()

TransactionManager.Instance.EnsureInTransaction(doc)

edgeArray = []
for r in region:
	geoElem = r.get_Geometry(geoOpt)
	enum1 = geoElem.GetEnumerator() ; enum1.MoveNext()
	geo2 = enum1.Current
	edgeArray.append(geo2.Edges)
	
lineStyles = []
lineLength = []
lineName = []
for reg in edgeArray:
	ls = []
	ll = []
	ln = []
	lineStyles.append(ls)
	lineLength.append(ll)
	lineName.append(ln)
	for edge in reg:
		ls.append(doc.GetElement(edge.GraphicsStyleId))
		ll.append(edge.ApproximateLength)
		ln.append(doc.GetElement(edge.GraphicsStyleId).Name)
TransactionManager.Instance.TransactionTaskDone()

#Assign your outputs to the OUT variable
OUT = lineStyles, lineName, lineLength

Code courtesy of @SeanP

FilledRegionLineStyles.dyn (10.5 KB)

4 Likes