sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [req]biggest segment of a selection

    Scheduled Pinned Locked Moved Plugins
    8 Posts 2 Posters 548 Views 2 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.
    • pilouP Offline
      pilou
      last edited by

      Don't remember if this yet existing 😳

      Biggest or smallest segment of a selection of segments
      0.001 precision

      Connex problem : the biggest distance between two curves ?
      0.001 precision

      Even without precision will be yet fine πŸ˜„

      Thx by advance

      Frenchy Pilou
      Is beautiful that please without concept!
      My Little site :)

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

        This one-liner copy+paste + <enter> in the Ruby Console highlights the longest segment in the selection and prints its length/id

        d=0;s=Sketchup.active_model.selection;a=s.to_a;q=nil;a.each{|e|(q=e;d=e.length) if e.class==Sketchup;;Edge and e.length>d};s.clear;s.add(q);puts d;q
        

        To return the greatest distance between two curves how do you mean to measure it - clearly its the distance between opposite ends! Or do you mean between matching vertices ?

        TIG

        1 Reply Last reply Reply Quote 0
        • pilouP Offline
          pilou
          last edited by

          Many thx! Works like a charm! 😎

          For the other thing

          @unknownuser said:

          Or do you mean between matching vertices ?

          yes πŸ˜‰

          Maybe this can help you β˜€
          But seems to me that your script gives the good answer as soons as segmemts are drawn between the 2 curves

          [flash=560,315:3421aels]http://www.youtube.com/v/m6Qww5j3C6g[/flash:3421aels]

          Frenchy Pilou
          Is beautiful that please without concept!
          My Little site :)

          1 Reply Last reply Reply Quote 0
          • pilouP Offline
            pilou
            last edited by

            I you have 2 similar biggest segments seems the first created is selected πŸ˜‰

            Frenchy Pilou
            Is beautiful that please without concept!
            My Little site :)

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

              Yes ?
              If you want the last change
              e.length>d
              to
              e.length>=d
              It you want an array of all edges of the max length it'd be relatively simple...
              After getting the max-length revisit the edges and compile an array of all edges with that length. Then add that array to the selection instead...

              TIG

              1 Reply Last reply Reply Quote 0
              • pilouP Offline
                pilou
                last edited by

                Thx I can easily change for have the last πŸ˜„

                That is an another story for the array or for the smallest! 😳

                Frenchy Pilou
                Is beautiful that please without concept!
                My Little site :)

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

                  This version returns the longest edge [if there are two equal the last one added is used]

                  d=0;s=Sketchup.active_model.selection;a=s.to_a;q=nil;a.each{|e|(q=e;d=e.length) if e.class==Sketchup;;Edge and e.length>=d};s.clear;s.add(q);puts d;q
                  

                  This one finds the shortest edge

                  d=0;s=Sketchup.active_model.selection;a=s.to_a;q=nil;a.each{|e|d=e.length if e.class==Sketchup;;Edge and e.length>d};a.each{|e|(q=e;d=e.length) if e.class==Sketchup;;Edge and e.length<=d};s.clear;s.add(q);puts d;q
                  

                  This version makes an array of all edges with the maximum length

                  d=0;s=Sketchup.active_model.selection;a=s.to_a;q=[];a.each{|e|d=e.length if e.class==Sketchup;;Edge and e.length>d};a.each{|e|q<<e if e.class==Sketchup;;Edge and e.length==d};s.clear;s.add(q);puts d;q
                  

                  This version makes an array of all edges with the minimum length

                  d=0;s=Sketchup.active_model.selection;a=s.to_a;q=[];a.each{|e|d=e.length if e.class==Sketchup;;Edge and e.length>d};a.each{|e|d=e.length if e.class==Sketchup;;Edge and e.length<=d};a.each{|e|q<<e if e.class==Sketchup;;Edge and e.length==d};s.clear;s.add(q);puts d;q
                  

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • pilouP Offline
                    pilou
                    last edited by

                    You rock as allways! πŸ‘
                    Thanks again! 😎

                    Frenchy Pilou
                    Is beautiful that please without concept!
                    My Little site :)

                    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