i would like to extract length of a pipe using python code. I don’t know how to use properties of a class. I wrote as shown below.
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
clr.AddReference(‘RevitApi’)
from Autodesk.Revit.DB import *
#from Autodesk.Revit.DB.HostedSweep import *
clr.AddReference(“RevitNodes”)
import Revit
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import *
from RevitServices.Transactions import *
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
sel = uidoc.Selection.GetElementIds()
stlist=
endlist=
length =
for i in sel:
item = (doc.GetElement(i))
loc = item.Location
len = item.Length
start = item.Location.Curve.GetEndPoint(0)
end = item.Location.Curve.GetEndPoint(1)
stlist.append(start)
endlist.append(end)
length.append(len)
OUT =stlist,endlist,length