Overall, this is a great solution. On paper there is …<10% difference in conduit length, but compared to real life situation this doesn’t affect anything.
2 Likes
# Enable Python support and load DesignScript library
import clr
# Import RevitAPI - This gives general access to Revit tools.
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# Import DocumentManager & TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
#Start Code
sel = uidoc.Selection.GetElementIds()
sel = [doc.GetElement(x) for x in sel]
op = Options()
l = 0
for item in sel:
try:
l += item.Location.Curve.Length
except:
c = [x for x in item.GetOriginalGeometry(op)
if isinstance(x, Arc) or isinstance(x, Line)]
l += sum([x.Length for x in c])
#Assign output
OUT = l
This is the python code I use to find the combined length of a selection in Revit. It adds the length parameter of the conduit, along with the length of any lines and arcs in your conduit fitting.
Which, for the fittings I use is just the centerline, so the calculation comes out correct.
Hi @vlad.aleksandrovs for get the Arc Length of Fittings maybe try this:
Element.Geometry + Extract only Geometry Arc (with “isinstance”) + Curve.Length + Math.Round
Cheers