Single script to select different things

 From:  Michael Gibson
11127.17 In reply to 11127.13 
Some more pieces to use for the 3 separate scripts:


> - one for dealing with objects: selects last-created objects if nothing is selected, otherwise
> looping through named objects (and it wouldn't matter if they are curves or not)

Nothing selected is detected like this:

code:
var selected_objs = moi.geometryDatabase.getSelectedObjects();

if ( selected_objs.length == 0 )
{
        .....
}


Selecting last created objects is: moi.geometryDatabase.selectLastCreated();

Stepping through named objects is the chunk of the script above that follows this:

/* If a named object is selected, deselect it and select the next one */


> - one for selecting edges (naked edges or edge loops / boundaries)

Selecting naked edges is the part of the script above with:
/* If surfaces are selected, select their naked edges */

Selecting edges of a face is this part:
/* 1 face selected, select edges of face */

Loop selection is this part:
/* If any edges are selected do loop selection */


> - one to select curves: it would loop through selecting open curves, closed curves, and all curves. even if nothing is selected.

Selecting all curves is the part marked with this:
/* If nothing selected, select all curves */

to select just open or closed curves, that would be like this:

code:
var curves = moi.geometryDatabase.getObjects().getCurves();

for ( var i = 0; i < curves.length; ++i )
{
    var crv = curves.item(i);
    if ( crv.isClosed )
        crv.selected = true;
}


- Michael