Error when adding a small facet? -- Points are not planar

I’m programmatically adding facets to the active model and noticed that adding small facets result in an exception.
Example in the Ruby console:

Sketchup.active_model.active_entities.add_face [[-0.0923144, 0.132364, 0.0182222], [-0.0921802, 0.132348, 0.0172238], [-0.0927674, 0.130992, 0.0172311]]

Error: #<ArgumentError: Points are not planar>
<main>:in `add_face'
<main>:in `<main>'
SketchUp:1:in `eval'

The three points are coplanar and are non-linear i.e. they define a proper plane. The only problem seems to be the fact that they are relatively close to each other because the exception goes away when I multiply all the coordinates by 1000 and add the facet.

In this case the exception is misinforming the actual cause.

Has anyone come across this before and found some form of workaround?

Thanks!

Everyone has come across it. SketchUp fails to create faces at small scales typically when edges are near 0.001 inch or smaller. The work-around is model large then scale down.

Search this forum for the problem and you will get many results including explanations and work- around workflows.

0.001 inch is SketchUp’s internal tolerance.

1 Like

That makes sense, thanks!

I agree. Since the error was due to the points being too close together, the message attached to the ArgumentError is misleading.

Error: #<ArgumentError: Points are not planar>

The error is misleading because ANY three points should always be “coplanar”.
You can of course force that message with four points where one in not coplanar.

However, if two [or all] of these three points are deemed coincident [because of the 1/1000" tolerance issue] then you do NOT have three distinct and separate points.
But in that case the error should be:

Error: #<ArgumentError: Not enough points - at least 3 required>

But it seems that the check for the validity for the number of points is preempted by the flaky coplanar check.

2 Likes

I would hope for a slightly better message string, like:

Error: #<ArgumentError: Not enough valid points - at least 3 non-coincident points required (having minimum 0.001" spacing.)>

… or it is “having co-ordinates” that differ by 0.001" ?


I would really prefer new custom exception classes that are easier to write rescue clauses for.

This kind of error is most similar to a FloatDomainError in behavior, but IMO should not be it’s subclass.

Like FloatDomainError, this error should probably be a subclass of RangeError. This would be proper to raise when a value or object does not “fit” within some range or set.

I would (if it were my call,) define such geometry creation errors with the API’s Geom module.

So some API-specific exceptions that would be beneficial:

  • Geom::CoincidentPointsError
  • Geom::CoplanarPointsError
  • Geom::NonCoplanarPointsError
  • Geom::NonCoincidentPointsError
  • Geom::ZeroDistanceError

etc. Anyone have better names or know any more ?

1 Like