[req]biggest segment of a selection
-
Don't remember if this yet existing
Biggest or smallest segment of a selection of segments
0.001 precisionConnex problem : the biggest distance between two curves ?
0.001 precisionEven without precision will be yet fine
Thx by advance
-
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 ?
-
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]
-
I you have 2 similar biggest segments seems the first created is selected
-
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... -
Thx I can easily change for have the last
That is an another story for the array or for the smallest!
-
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
-
You rock as allways!
Thanks again!
Advertisement