Select behavior on multidirection

Hi all.
I have big drawing firefighting need taging to all pipe once. But tag going on all pipe. I try to make vertical and horizantaly seprate and on top view b & c also want seprate selection behavior example is image. Mention
In drawing i have 3 types pipe a is rizer b is top view but 180 degree and c is 90 degree direction.
How i make 3 option for 3 type slection
Can you guide me fore coding or .dyn

  1. Take all the pipes.
  2. Get the pipe’s location curves.
  3. Get the direction of each pipe’s curve using a Curve.TangentAtParameter node with a parameter value of 0.5.
  4. Pull the Z component of each vector using a Vector.Z node.
  5. Test that Z value for not being equal to 0 with a != node.
  6. Use an If node to return a value of “vertical” if true, otherwise return null.
  7. Pull the X and Y components of the vectors in step 3 (Vector.X and Vector.Y nodes).
  8. Get the absolute value of the X and Y values with a pair of Math.Abs nodes.
  9. Test the absolute value of X against the absolute value of Y with a >= node.
  10. Use an if node to return “X primary” if true, or “Y primary” if false.
  11. Join the two tests (step 6 and step 10) together into one list.
  12. Use a List.Transpose to put the entirety of each pipe’s tests into a single list.
  13. Use a List.Clean node with a ‘false’ input to the preserve indices to remove any null values.
  14. Use a List.FirstItem node with the List level set to @L2 to get the first value out of the list.
  15. Use a List.GroupByKey node to group each of the pipes (step 1) by their primary direction (step 14).
  16. Create a dictionary of the groups, using the keys as the dictionary value. This will ensure that you can call for the Vertical, X primary or Y Primary as desired, even if a direction wasn’t present (ie: there are no vertical pipes in the original selection).
  17. Proceed to tag each pipe type as desired using your tag automation of choice.

This thing very hard for me.
Today i get something like this but i want this horizantal two different directions in seprate.
Image and dynmo. Attached.

Horizantal or Vertically pipe Selection.dyn (22.1 KB)