Orientation/"up-direction" of ducts and pipes

I need to place elements at the intersection between ducts/pipes and floors, and then rotate the new element accordingly, depending on the orientation of the duct/pipe.
This is no issue with horizontal pipes or ducts, but I cannot figure out how to determine the orientation of a vertical duct/pipe. I can calculate a vector from its start and endpoint (either (0,0,1) og (0,0,-1)), but I have no way of relating that to the horizontal plane.

I have had the same issue with cable trays, until I realised that they have an up-direction property that returns exactly what I needed, but as far as I can tell, neither ducts nor pipes have similar properties.

Any thoughts on how to approach this?
Thanks!

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

element = UnwrapElement(IN[0])

OUT = element.CurveNormal.ToVector()

@sebastianjust.jensen Please share your relevant file (dyn, rvt and the family you’d like to place)

Did you find an answer yet?

Hey, I’m pretty sure I gave up at the time and I don’t really use Dynamo anymore. I just skimmed through the API and it appears to still not be available OOTB, so I guess you would have to do a more elaborate analysis on the connecting ducts/pipes to figure out which way it’s oriented. I do not have any such code at the moment, but I’ll post it here if I ever look into it again.

These nodes from MEPover for getting the directions of the connectors that are on either side of the ducts might be useful.

3 Likes

Mhm, that’s a good point. I guess either the X or Y direction of the base connector should be enough to determine it. I’m assuming you get a minimum of two coordinate systems from each connector element, in which case you’d just need to get the one with a vertical Z-vector.