perp-perp distance analysis

 From:  Michael Gibson
4547.17 In reply to 4547.16 
Hi Pilou,

> Does it possible to have the smallest curve ?

Yup, this script will select the smallest curve instead:

script: /* select shortest curve */ var curves = moi.geometryDatabase.getObjects().getCurves(); var minlen = 1e100; var mincrv = null; for ( var i = 0; i < curves.length; ++i ) { var crv = curves.item(i); if ( crv.hidden || crv.locked ) { continue; } var thislen = crv.getLength(); if ( thislen < minlen ) { minlen = thislen; mincrv = crv; } } if ( mincrv != null ) mincrv.selected = true;


> Ps What happen if there are 2 biggest equal?
> Seem the first created is selected :)

Yup, that's correct.


> Pss And it's a curious workflow : nothing must be selected
> before lauch the script!

Yup, it adds the shortest or longest one to the selection without disturbing other already selected objects. That allows for more flexibility - for example if you want to select both the shortest and the longest curve you can start with nothing selected and then run both of those scripts and you'll then have that selection at the end. If each script cleared the selection first then it wouldn't be possible to do that anymore.

But if you do want everything else to be deselected, it's possible to do that by adding a call to moi.geometryDatabase.deselectAll(); at the start of the scripts.

- Michael