Picking Vertical Faces

I thought the API has a built in detection for rounding off floats, or some sort of tolerance, correct me if I’m wrong.

I’m trying to take a collection of faces and eliminate the vertical faces:

@roof_faces = @all_roof_faces.find_all {|f| f.normal.z != 0.0 }

This sort of works but the results are unpredictable.

This seems to work:

@roof_faces = @all_roof_faces.find_all {|f| f.normal.z.round(3) != 0.0 }

Try …

@roof_faces = @all_roof_faces.reject {|f| f.normal.perpendicular?(Z_AXIS) }

You’re wrong. It’s Core Ruby that has this functionality. :wink:

1 Like

That is the cleaner way to handle the task.

The Length class compares with the tolerance SketchUp use for length units. But if you have a Float you need to perform this yourself.

In the example you provide you are dealing with geometric coordiantes so it’d be appropriate to ensure you use Lengths:

@roof_faces = @all_roof_faces.find_all {|f| f.normal.z.to_l != 0.to_l }