Loose planar check to add_face


#1

Hi,

I read in 4 points from a file. They are a bit off plain. Say the first 3 points sit in a Z=100 plain, but the 4th point is at Z=100.005. When add_face from these 4 points, the Error is: #<ArgumentError: Points are not planar>.

Just wondering is there a way I could loose that planar check, ignore the 0.005 difference, so I could add that face. I need the 4th point to keep the shape.

Thanks in advance.

Regards,

John


#2

A face is planar by definition. If SketchUp were able to allow adding a face with non-planar points, problems would arise elsewhere in math because algorithms are based on the definition that faces are planar. To avoid unpredictable behavior, SketchUp fails as early as possible, namely at the input of data.

You have two options:

  • Add a face with planar points by correcting the fourth point. You can use Ruby API methods to check planarity, to compute the average plane of some points or detect the outlier. You can project the outlier to the plane of the non-outliers.
  • Add two triangles. Triangles are always planar because a plane in 3d space can be clearly defined by three points. Some people hide, soften or smoothen the diagonal dividing edge if they still want it to appear like a quadrilateral.

#3

Thanks. I’ll try to project the outlier. The face need to be pulled later.


#4

I think it is possible to use Geom.fit_plane_to_points(point1, point2, point3, point4) method.
Or maybe just to iterate through all given points and force equal “z” coordinate before add_face in case if plane should be always horizontal. In case if I understood the question correctly.


#5

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.