sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Add_face gives error duplicate point in array

    Scheduled Pinned Locked Moved Developers' Forum
    16 Posts 3 Posters 2.4k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G Offline
      Garry K
      last edited by

      I don't really know - but there are about 130 faces for a basic curved stair and I only have to test this for 2 of those 130 faces. This seems to work really well now - unless I'm missing something.

      1 Reply Last reply Reply Quote 0
      • G Offline
        Garry K
        last edited by

        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.


        Where stringer meets the floor


        Other side

        1 Reply Last reply Reply Quote 0
        • tt_suT Offline
          tt_su
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • jolranJ Offline
            jolran
            last edited by

            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 😕

            1 Reply Last reply Reply Quote 0
            • jolranJ Offline
              jolran
              last edited by

              @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?

              1 Reply Last reply Reply Quote 0
              • tt_suT Offline
                tt_su
                last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • tt_suT Offline
                  tt_su
                  last edited by

                  @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.

                  1 Reply Last reply Reply Quote 0
                  • tt_suT Offline
                    tt_su
                    last edited by

                    FYI, the reason for this tolerance is due to floating point tolerance: http://floating-point-gui.de/

                    1 Reply Last reply Reply Quote 0
                    • jolranJ Offline
                      jolran
                      last edited by

                      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.

                      1 Reply Last reply Reply Quote 0
                      • G Offline
                        Garry K
                        last edited by

                        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.

                        1 Reply Last reply Reply Quote 0
                        • tt_suT Offline
                          tt_su
                          last edited by

                          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.

                          1 Reply Last reply Reply Quote 0
                          • G Offline
                            Garry K
                            last edited by

                            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 !!

                            1 Reply Last reply Reply Quote 0
                            • G Offline
                              Garry K
                              last edited by

                              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 )
                              end

                              Any thoughts on this?


                              Illustrates Collinear issue

                              1 Reply Last reply Reply Quote 0
                              • 1 / 1
                              • First post
                                Last post
                              Buy SketchPlus
                              Buy SUbD
                              Buy WrapR
                              Buy eBook
                              Buy Modelur
                              Buy Vertex Tools
                              Buy SketchCuisine
                              Buy FormFonts

                              Advertisement