Hi,
I would like to know the total length of different line style in the region,
However, I don’t know how to get the Line Style information from the region…
Any suggestions?
Hi,
I would like to know the total length of different line style in the region,
However, I don’t know how to get the Line Style information from the region…
Any suggestions?
Hi,
thank you so much for the quick reply.
Though I saw that the dynamo is selecting the line elements,
but I was hoping to select the region and filter out the linestlye that are used in the 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
FilledRegionLineStyles.dyn (10.5 KB)
Hello @AmolShah,
This is brilliant!! Exactly what I need!
Thank you so much!!