Straighten vertical of conduit

I think trying to straighten them automatically is too risky & unpredictable.

I’d suggest calculating the vector between start and end points, and using this to work out which are vertical (or orthogonal) and identify them e.g. setting a parameter, changing color etc

In the below example, I compare the conduit vector to the vector of the nearest major axis, and set a parameter accordingly. A view filter changes the color (green=orthogonal)

The sin() is there because depending on the direction of the conduit, an orthogonal conduit may be calculated as either either 180 or zero degrees
With the way Revit displays units, I have had to add a ‘fudge factor’- conduits which snapped to be orthogonal may report a angle of 179.999999999 degrees. My sine 0.01 is about 0.6 degree
These conduits (not green) can then be corrected manually.

Andrew