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

    Pointcloud - Joining the Dots

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    14 Posts 4 Posters 465 Views 4 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      Of course, that sample code only draws new edges.
      But you could easily add a command to 'force faces' for the new_edges if required.
      next if pp==pt ### trap for coincident points in CSV new_edge=ent.add_line(pp,pt) new_edge.find_face

      Also it'd be much 'safer' if you included a group thus
      ents=mod.**active_**entities
      then
      gp=ents.add_group() gp.name=File.basename(@csv_file, ".*")
      and then
      ent=gp.entities
      before adding the edges/faces into ent - so the new mesh's geometry is kept quite separate from other existing geometry etc...

      TIG

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

        The attached file will hopefully illustrate what I'm trying to achieve. (Please ignore my ridiculous scale)

        The Point-cloud consists of six individual Point-clouds of 360 points. Each describing the inner or the outer edge of an ellipse resulting in three different, flat elliptical rings.

        The intention is to create a solid ring from these, two representing the side of the solid and the remaining, the middle. It is the edge forms of this solid ring that I wish to achieve, more quickly than I have been able.

        The 'stitching' that I have done in the attached file joins the outer points n together and similarly the inner points n.

        The edge form is covered (triangulated) by joining sides n to middle n+1 from 0 to 180 and by joining sides n to middle n-1 from 181 to 360.

        Having articulated this, I realise now, that this could be coded but I have no knowledge how it might be dome.


        PLEASE EXCUSE THE RIDICULOUS SCALE

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

          This could be coded - sdmitch is probably on to it as I type!
          The 'manual' way can be done much easier if you subgroup the cpoints in sets and overdraw them.
          Then use a tool like CurviLoft or EEbyRails on the 'face's edges/curves to make individual meshes for each of the four faces of the ring [the centerline seems superfluous??]


          Equatorial TriRing.PNG


          Equatorial TriRing.skp

          TIG

          1 Reply Last reply Reply Quote 0
          • sdmitchS Offline
            sdmitch
            last edited by

            What defines the 3rd ring?

            I used this code to triangulate two of them after I figured out how they were ordered in the model.

            mod = Sketchup.active_model
            ent = mod.entities
            sel = mod.selection
            # collect the construction point locations in groups of 360
            pts=[];ring=[]
            ent.each{|e|
             if e.class==Sketchup;;ConstructionPoint
              ring<<e.position
              if ring.length>=360
               pts<<ring;
               ring=[]
              end
             end
            }
            # triangulate the rings
            for i in 0...360
            
             ent.add_face(pts[0][i],pts[2][i-1],pts[2][i])
             ent.add_face(pts[0][i],pts[0][i-1],pts[2][i-1])
             ent.add_face(pts[0][i],pts[4][i-1],pts[4][i])
             ent.add_face(pts[0][i],pts[0][i-1],pts[4][i-1])
            
             ent.add_face(pts[1][i],pts[3][i-1],pts[3][i])
             ent.add_face(pts[1][i],pts[1][i-1],pts[3][i-1])
             ent.add_face(pts[1][i],pts[5][i-1],pts[5][i])
             ent.add_face(pts[1][i],pts[1][i-1],pts[5][i-1])
            
            end
            
            

            Equatorial TriRing2.skp

            Nothing is worthless, it can always be used as a bad example.

            http://sdmitch.blogspot.com/

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

              The central ring isn't superfluous. It was unfortunate that I chose the 0/360 point to example my triangulation as both the inner and outer edge forms show little cross sectional form at this point unlike at 90. The inner edge form's concave, the outer, convex.

              I'm not at home as I write. I will use your ideas as soon as I can though. Unfortunately, I've not the first idea how to code. Thank you

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

                Thank you Sam!

                Not having done any coding, would you mind telling me how I can use the code that you've made?

                1 Reply Last reply Reply Quote 0
                • sdmitchS Offline
                  sdmitch
                  last edited by

                  It needs to be included in a method and a module to identify and isolate it from the other plugins that may be loaded. I have made the necessary additions to allow you to copy the plugin to the plugins folder and have it appear in the plugins menu.

                  Please understand that this plugin, as written, applies to this single case only and the construction points near the model origin must be deleted before the plugin is run so that there are only the 2160 construction points that define the 6 rings.


                  Joining The Dots.rb

                  Nothing is worthless, it can always be used as a bad example.

                  http://sdmitch.blogspot.com/

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    mac1
                    last edited by

                    This is some what off topic so please delete if not correct;
                    I attempted to convert skp file to dae and then see what MeshLab does with the data but it appears dae does not convert cpoints and only the vertices are showing??
                    There is a plugin to go from vertex to cpoint. Is there one for the cpoint to vertex??

                    1 Reply Last reply Reply Quote 0
                    • sdmitchS Offline
                      sdmitch
                      last edited by

                      My guess is no because you would have lost the relationship between the vertices that have been converted to construction points.

                      Nothing is worthless, it can always be used as a bad example.

                      http://sdmitch.blogspot.com/

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

                        @sdmitch said:

                        It needs to be included in a method and a module to identify and isolate it from the other plugins that may be loaded. I have made the necessary additions to allow you to copy the plugin to the plugins folder and have it appear in the plugins menu.

                        Please understand that this plugin, as written, applies to this single case only and the construction points near the model origin must be deleted before the plugin is run so that there are only the 2160 construction points that define the 6 rings.

                        While trying not to appear stupid, I must ask what you mean by '......included in a method and a module and isolate it from other plugins....

                        ...... would you mind explaining as if I am?

                        1 Reply Last reply Reply Quote 0
                        • sdmitchS Offline
                          sdmitch
                          last edited by

                          In Ruby, sub-routines are refered to as methods and are defined by "def method_name" as the first line and "end" as the last line. Modules contain any number of methods and are defined by "module Module_Name" as the first line and "end" as the last line. When a method is placed inside a module, it is normally coded def self.method_name where self. refers to the module containing it. Two modules can contain methods with same name but do different things and there is no conflict because the modules will have different names.

                          You should get a Ruby programming reference book if you ever expect to read and understand what the various code statements mean.

                          Nothing is worthless, it can always be used as a bad example.

                          http://sdmitch.blogspot.com/

                          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