I had a go at this and something with my math/thinking is a miss… While with lots of points it looks like it does the job with only a half dozen you will see its missed some out… I will see if I can get my head around this… math is not my strongest point (where's jong when you need him). May be someone else can spot the error while I smash my head on the desk again…
This is how I tried…
#target illustrator
var doc = app.activeDocument;
var sel = doc.selection;
var pp = Array();
for ( var i = 0; i < sel.length; i++ ) {
if ( sel.typename == 'PathItem' ) {
pp.push(sel.pathPoints[0].anchor);
}
}
//$.writeln(pp.length);
//$.writeln(pp.toString());
var split = Math.round(pp.length/2);
do {
for ( var j = 1; j < pp.length; j++ ) {
var line = doc.pathItems.add();
lpp = Array();
lpp.push(pp[0]);
lpp.push(pp);
line.setEntirePath(lpp);
}
pp.shift();
//$.writeln(pp.length);
//$.writeln(pp.toString());
} while (pp.length >= split)
app.redraw();
Wooooooooo… I may have got it now… My head logic of the needing to spit was plain wrong… Try this…
#target illustrator
var doc = app.activeDocument;
var sel = doc.selection;
var pp = Array();
for ( var i = 0; i < sel.length; i++ ) {
if ( sel.typename == 'PathItem' ) {
pp.push(sel.pathPoints[0].anchor);
}
}
if (pp.length >= 2) {
do {
for ( var j = 1; j < pp.length; j++ ) {
var line = doc.pathItems.add();
lpp = Array();
lpp.push(pp[0]);
lpp.push(pp);
line.setEntirePath(lpp);
app.redraw();
$.sleep(500);
}
pp.shift();
} while (pp.length >= 2)
app.redraw();
}