If you want to filter all horizontal lines, you can calculate the dot product of the lines and a Z vector. The dot product of a horizontal line is 0, as is the cosine of the angle.
If need to get specific horizontal lines in a certain Z , not all of them, they way you are proposing, I can’t separate them.
By chosing start Z and end Z I think is a good way. No ?
By selecting start Z and end Z someone can get all kind of lines, not only the horizontal ones.