• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Plugin to create all possible lines between points

Scheduled Pinned Locked Moved Plugins
6 Posts 3 Posters 315 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.
  • L Offline
    liquid98
    last edited by 22 Nov 2011, 18:14

    Hi,

    My first question:

    I have a set of construction points, which coordinates I want to catch in an Array.
    How do I do that?

    Second question:

    I want to draw al the possible lines to connect all the cpoints in that Array.

    I think I have to use line = entities.add_line point1,point2

    But how do I iterate through the couples in the array?

    Examplearray = [A, B, C]

    Gives me these three couples / lines:
    AB
    AC
    BC

    And of course BA CA and CB but these are duplicate lines..

    But how to automate this process??

    Thanxs for your input!

    Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

    1 Reply Last reply Reply Quote 0
    • F Offline
      fredo6
      last edited by 22 Nov 2011, 20:30

      @liquid98 said:

      Hi,

      My first question:

      I have a set of construction points, which coordinates I want to catch in an Array.
      How do I do that?

      Second question:

      I want to draw al the possible lines to connect all the cpoints in that Array.

      I think I have to use line = entities.add_line point1,point2

      But how do I iterate through the couples in the array?

      Examplearray = [A, B, C]

      Gives me these three couples / lines:
      AB
      AC
      BC

      And of course BA CA and CB but these are duplicate lines..

      But how to automate this process??

      Thanxs for your input!

      1. For the first question, you have to tell how is the "set of construction point", i.e., is it a list of Point3d? if so, you get the [x, y, z] of a Point3d <pt> with pt.to_a

      2. For the multi-connection, use that code

      
      def messy_connect_points(entities, list_points)
         n = list_points.length - 1
         for i in 0..n
             pti = list_points[i]
             for j in i+1..n
                 entities.add_line pti, list_points[j]
             end
         end
      end
      
      

      Fredo

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdmitch
        last edited by 22 Nov 2011, 20:38

        if the construction points are in the model

        mod = Sketchup.active_model
        ent = mod.entities
        sel = mod.selection
        pts=[];#initialize the points array
        #find all the construction points
        ent.each{|p| pts.push p.position if p.is_a?(Sketchup;;ConstructionPoint)}
        #draw all possible lines
        for i in 0...pts.length-1
          for j in 1...pts.length
            ent.add_line(pts[i],pts[j])
          end
        end
        
        

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

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • L Offline
          liquid98
          last edited by 22 Nov 2011, 20:45

          Hi Sam and Fredo,

          Thnx for your help! Exactly what I was after..

          @Sam
          pts=[];#initialize the points array
          why the ; ??

          Thnx

          Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdmitch
            last edited by 22 Nov 2011, 20:50

            force of habit. the ; just seperates multiple statements on a single line. In this case the # is used to comment the remainder of the line.

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

            http://sdmitch.blogspot.com/

            1 Reply Last reply Reply Quote 0
            • L Offline
              liquid98
              last edited by 22 Nov 2011, 21:00

              Sam,

              Well, I'm supposed to know the use of the ; but i forgot..

              Again thanx for your help. The Math part was easier than the constructionpointarraycreation. 😄

              Things that flourish fall into decay. This is not-Tao, And what is not-Tao soon ends ~ Lao tse

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

              Advertisement