Add_face gives error duplicate point in array
-
You see where the stringer transitions and meets the floor. It just happens that the transition point is just about at the same place where the 2 faces meet.
Most of the time it is more like the outside stringer on the second picture. Here I need the point.
-
@garry k said:
The second point is the culprit. Does anyone know how close 2 points can be without producing an error?
SketchUp's internal tolerance is 1/1000th of an inch. Comparing two Geom::Point3d objects using == will use this tolerance.
-
Right, I see... There is some quite complex code going on..
Actually I was probably too fast earlier. the API actually says:
@unknownuser said:
you can use the Array class in place of a Point3d or Vector3d as a way to pass coordinate values.
If you got duplicates Array.uniq! should do the trick though
-
@unknownuser said:
SketchUp's internal tolerance is 1/1000th of an inch. Comparing two Geom::Point3d objects using == will use this tolerance.
Getting position values from a mathematical computation one should convert results to Point3d objects before comparison, right?
-
@jolran said:
If you got duplicates Array.uniq! should do the trick though
That would only work when the numeric values are identical. But that would not filter out points from this error. If they are within tolerance they are considered identical.
-
@jolran said:
Getting position values from a mathematical computation one should convert results to Point3d objects before comparison, right?
What would ensure the data is treated fully as 3D points and handled using the internal tolerance, correct.
-
FYI, the reason for this tolerance is due to floating point tolerance: http://floating-point-gui.de/
-
Floating Point comparison confuses the hell out of me.
Think you had a similar disucssion in an earlier post somewhere some time ago.This is reassuring, thanks.
-
There are a few things we do when dealing with floating point, especially during reporting.
For instance, you have a report that sums up a lot of floating point values all coming out of a data base. What I do is make sure that I round all data going into the database to x decimals. Consider this your tolerance. If it is money in US dollars that is being reported to 2 decimal places then I store to 3. Every time I perform a math operation on the data - I round it. This ensures that if you add up items individually in the report that they sum up properly.
Essentially this is the same thing. SU must store the data after internally rounding it in 3D space.
I've also worked with a lot of raw GPS device. We needed to apply logic to reduce wander while vehicles are stopped. Otherwise the vehicles would accumulate small amounts of movement over time. Sitting in traffic in urban canyons ( tall buildings ) has its own challenges.
I digress. In this case I push Point3D values into an array - or collection. Essentially perform rounding by testing for equivalency. I also needed to work with Point3D values so that intersect_line_line etc. work properly.
-
If you want to push a bunch of points into a set, and merge points that SketchUp thinks of as identical, you can use the PolygonMesh class. Just add the points and SU will merge similar points.
-
OK - the first situation with duplicate point in array error has been handled.
Now I get something a bit different
Adding these points to a face I get
(-96.638256mm, 2398.053596mm, 2351.973324mm)
(-96.678788mm, 2398.051144mm, 2352mm)
(-96.638256mm, 2398.053596mm, 2352mm)Error: #<ArgumentError: Points are not planar>
I have read some old threads some time in 2008 where someone got the same error and it was suggested that this error should actually say something like : Points are collinear.
Does anyone know what the tolerance for collinearity is:
Doing the math - none of these three points would be considered as duplicate as the distance between each exceeds the 1/1000 of an inch.
Also - if it is suggested to use a PolygonMesh - I have tried - but haven't got it to work. A working example would be appreciated !!
-
In this example I increased the width of the stringer which results in a small triangle that you can see. Width is 304 mm.
Where the sketchup error occurs the stringer width was 300 mm and the small triangle would not be visible at this zoom.
What I have done for now, which works in these type of situations, is simply use a rescue block. I would normally consider this bad form as it can hide errors. This code only works on the last section when the stair has a heel and when we should have a triangle. The sketchup error was misleading and cost me a bit of time trying to track this down.
begin
# try to add the face
ent.add_face( pts )
rescue
puts( pts ) if ( debug_level > 0 )
endAny thoughts on this?
Advertisement