REVIT MEP - how to proceed to find the unevenness between the pipe before the beginning of the section and the last point of the section

Good afternoon,

I need to perform a subtraction following the direction of the fluid, in the image below, it can be seen that the pipe connections and accessories of pipes and plumbing parts there is a parameter “Pipe Stretch”, which in revit is also defined as a section.

in my routine, she separates all pipes, connections and pipe fittings and plumbing parts according to the section/pipe section parameter, right after that she removes all the pipes that are horizontal, and collects the position/location in the Z exit.

now I need this routine to perform the following task, the section “1-2” subtract the section “2-3” and so on, but when there is only one tube in the section the dynamo works correctly the problem happens when there is more of a horizontal tube belonging to the same stretch, for example below in the image has a better explanation.


@Tiago Try this:

	OUT = [x[0]-IN[0][i+1][0] if len(x) == 1 else x[0]-x[1] for i,x in enumerate(IN[0])]
	OUT = [x[0]-IN[0][i+1][0] if len(x) == 1 else x[0]-x[1] for i,x in enumerate(IN[0])][:-1]

thx but not work.

I tried to use your code python with the tubes collecting only the first tube horizontally in the stretch and the last one before the next stretch following the fluid flow upstream?