Slope in Pipes - Separate Horizontal and Verical elements

Hi guys, i have a dynamo rotine when i can filter the pipes in a open view and then i can get their Slopes and filter all the pipes that does not have slope >= 1%. The goal is see all the pipes that should have slope but does not have and paint them with override elements so the designer can see and fix it.

With dynamo is easy to have the slope of horizontal pipes because all vertical pipes has this information in their slope parameter: “Not Computed” and inside the Dynamo this parameter is Empty then is very easy to separate the horizontal to vertical and i just need to create a condicional among the pipes who have a value in % and override all with slope less than 1%.

now i am trying to create a plugin with pyrevit using the same idea but as you can see below the built in parameter RBS_PIPE_SLOPE the vertical pipe who has slope: “Not Computed” in revit has the built in parameter 0.00% and he will be overrided wrongly.

Anyone know how can i separate horizontal and vertical pipes in revit API?

Thanks! :smiley:

I do not do a bunch with MEP stuff so this may not be the best approach but an easy way would be to get the pipes curve and then the endpoints. Then get the XYZ or each end. If X and Y are the same but Z is different then you have a vertical pipe.

You could use this as an example. It is from GeniusLoci package in Dynamo and you can amend it for pyRevit.

#Alban de Chasteigner 2020
#twitter : @geniusloci_bim
#geniusloci.bim@gmail.com

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

elements = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]
	
horizontal,vertical, slope =[],[],[]

for element in elements:
	if hasattr(element, "Explode"):
		curve=element.ToRevitType()
	elif hasattr(element, "Location") and isinstance(element.Location, Autodesk.Revit.DB.LocationCurve):
		curve=element.Location.Curve
	if round(curve.GetEndPoint(0).Z,2) == round(curve.GetEndPoint(1).Z,2):
		horizontal.append(element)
	elif round(curve.GetEndPoint(0).X,2) == round(curve.GetEndPoint(1).X,2) and round(curve.GetEndPoint(0).Y,2) == round(curve.GetEndPoint(1).Y,2):
		vertical.append(element)
	else: slope.append(element)
	
if isinstance(IN[0], (list)): OUT = vertical,horizontal,slope
else: OUT = vertical[0],horizontal[0],slope[0]