is it possible to retrieve the curve from a pipe elbow (fabrication part) by using python
Hi,
a solution using the CoordinateSystem of the connectors of the elbow (fabrication part)
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
def get_elbow_curve(fabPart):
"""
return the arc geometry of elbow fabrication part
"""
conSet = fabPart.ConnectorManager.Connectors
if conSet.Size == 2:
pair_sys_origin = [[con.CoordinateSystem, con.Origin] for con in conSet]
pta = pair_sys_origin[0][1].ToPoint()
ptb = pair_sys_origin[1][1].ToPoint()
vector = pair_sys_origin[0][0].BasisZ.Negate().ToVector()
arc = DS.Arc.ByStartPointEndPointStartTangent(pta, ptb, vector)
return arc
else:
return None #The fitting have more than 2 connectors
toList = lambda x : x if hasattr(x, '__iter__') else [x]
#Preparing input from dynamo to revit
lstfitting = toList(UnwrapElement(IN[0]))
OUT = [get_elbow_curve(e) for e in lstfitting]
1 Like