sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [REQ] label points with same X,Y Coordinates -pointcloud aid

    Scheduled Pinned Locked Moved Plugins
    6 Posts 3 Posters 1.1k 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.
    • halroachH Offline
      halroach
      last edited by

      Using points_cloud_triangulation.rb

      In some cases there are whole areas that aren't triangulated, or areas that the triangulation is overlapping. (see images)
      following the error message in the console, I figured that the problem occurs when there are points that share a common X,Y coordinate (on a different Z).

      It is a tedious task to find these points throughout a large model. I was wondering if there might be a script to label points that share the same Z? something similar to labeling stray lines - in "stray lines.rb".
      Or if anybody knows how to write a script that would do that!?


      point cloud


      applying points_cloud_triangulation.rb


      points sharing same X,Y coordinates


      error message from points_cloud_triangulation.rb

      FlexTools - Super Quick Windows, Doors, Slats...

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Try this

        require 'sketchup.rb'
        def cpointseqxy()
          model=Sketchup.active_model
          ents=model.active_entities
          layers=model.layers
          tlayer=layers.add("cpointseqxy")
          sel=model.selection
          sela=sel.to_a
          sel.clear
          model.start_operation("cpointseqxy")
          cs=[]
          ca=[]
          sela.each{|e|
            cs<< e if e.class==Sketchup;;ConstructionPoint
            ca<< e if e.class==Sketchup;;ConstructionPoint
          }
          th=[]
          ch=[]
          lh=[]
          ca.each{|c|
            cx=[]
            cs.each{|e|
              next if c.to_s == e.to_s 
              if c.position.x == e.position.x and c.position.y == e.position.y
                cx<< e
                ch<< e
                t=ents.add_text(" =XY",e.position)
                th<< t
                l=ents.add_cline(c.position,e.position)
                lh<< l
              end#if
            }
            cs=cs-cx
          }
          th.each{|t|t.layer=tlayer}
          lh.each{|l|l.layer=tlayer}
          sel.add(th+ch+lh)
          model.commit_operation
        end
        

        Copy + Paste the code into a file in the Plugins folder called cpointseqxy.rb.
        Restart SUp and select everything [only cpoints get processes anyway].
        In the Ruby Console type cpointseqxy and all cpoints with common X & Y values are highlighted and highlighted =XY text is added next to each of them, also a highlighted vertical cline is added between them. Note that the text and clines are also put onto a layer called 'cpointseqxy' - so you can isolate them or delete them more easily [by deleting the layer and its contents]... 🤓

        TIG

        1 Reply Last reply Reply Quote 0
        • Didier BurD Offline
          Didier Bur
          last edited by

          Hi,

          @unknownuser said:

          the problem occurs when there are points that share a common X,Y coordinate (on a different Z)

          Correct. Delauney algorithm is a 2D triangulation process, sort of. Having 2 points at the same location (plan view) breaks it.

          Note: the "Points are not planar" error can also occur if 2 points are very very very close to each other. It is a Sketchup "add_face" method issue, IMHO.

          DB

          1 Reply Last reply Reply Quote 0
          • halroachH Offline
            halroach
            last edited by

            Very nice TIG! You're the man!
            It works wonderfully! 😍

            Could you have the text that's added, with arrows just like in "straylines.rb". I think it would make it easier on the eyes to find the points. I've added one arrow to demonstrate the difference, see attached image.

            Thanks! really great!!

            plugin works like a charm + would look better with arrows

            FlexTools - Super Quick Windows, Doors, Slats...

            1 Reply Last reply Reply Quote 0
            • halroachH Offline
              halroach
              last edited by

              @didier bur said:

              Note: the "Points are not planar" error can also occur if 2 points are very very very close to each other. It is a Sketchup "add_face" method issue, IMHO.

              There is a way to overcome the problem of very close points not closing faces. scale the the model x10. add the faces, and then rescale by .1. It usually works.

              Thanks guys!

              FlexTools - Super Quick Windows, Doors, Slats...

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                Try this

                
                require 'sketchup.rb'
                    def cpointseqxy()
                      model=Sketchup.active_model
                      ents=model.active_entities
                      layers=model.layers
                      tlayer=layers.add("cpointseqxy")
                      sel=model.selection
                      sela=sel.to_a
                      sel.clear
                      vec=[10,10,10] ### change these values for arrow length
                      model.start_operation("cpointseqxy")
                      cs=[]
                      ca=[]
                      sela.each{|e|
                        cs<< e if e.class==Sketchup;;ConstructionPoint
                        ca<< e if e.class==Sketchup;;ConstructionPoint
                      }
                      th=[]
                      ch=[]
                      lh=[]
                      ca.each{|c|
                        cx=[]
                        cs.each{|e|
                          next if c.to_s == e.to_s
                          if c.position.x == e.position.x and c.position.y == e.position.y
                            cx<< e
                            ch<< e
                            t=ents.add_text(" =XY",e.position,vec)
                            th<< t
                            l=ents.add_cline(c.position,e.position)
                            lh<< l
                          end#if
                        }
                        cs=cs-cx
                      }
                      th.each{|t|t.layer=tlayer}
                      lh.each{|l|l.layer=tlayer}
                      sel.add(th+ch+lh)
                      model.commit_operation
                    end
                

                This has arrows for the text: vec=[10,10,10] sets the arrows 'vector', adjust the value of it to change the leader location, length etc...

                TIG

                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