[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;qTo 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;qThis 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;qThis 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;qThis 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!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement