Optimize objects stacking order for vinyl cutting
Hello,
i am looking for a script for optimizing vinyl cutting speed.
The script should be similar to following , but needs to sort the selected objects by the relative position to page origin and not the height from page origin as it does now
script from Arranging stacking order from top to bottm
//David Entwistle
var thisDoc = activeDocument;
// get selected objects
var selObj = thisDoc.selection;
// count the selected objects
var selObjCount = selObj.length;
// sort selected objects by their height from the page origin
var byProperty = function(prop) {
return function(a,b) {
if (typeof a[prop] == "number") {
return (a[prop] - b[prop]);
} else {
return ((a[prop] < b[prop]) ? -1 : ((a[prop] > b[prop]) ? 1 : 0));
}
};
};
var symbolsSorted = selObj.sort(byProperty("top"));
// for each object in turn in the ordered selection, BringToFront
for(i = selObjCount; i >0; i--){
var currObj = symbolsSorted[i-1];
currObj.zOrder(ZOrderMethod.BRINGTOFRONT);
}
redraw();
alert("Selected Objects Sorted = " + selObjCount);
Any help is welcome
Panagiotis
