Trying to Compare Geometric Bounds if Many items are Selected instead of two items
Hi Experts,
I was comparing the geometric bounds for just two selected items, so the following simple script will just test if the two selected items are different is size or not so it will (de-Select) one of them, can this script updated to select any items to comapre them and de-select all the items that are matching in geometric size instead of only two items?, here is the starting script :
//Test Two Selected items Gemoetry Size
var item1 = app.selection[0];
var item2 = app.selection[1];
//for Item 1
var myWidth1 = Math.round(item1.geometricBounds[3]-item1.geometricBounds[1]);
var myHeight1 = Math.round(item1.geometricBounds[2]-item1.geometricBounds[0]);
//for Item 2
var myWidth2 = Math.round(item2.geometricBounds[3]-item2.geometricBounds[1]);
var myHeight2 = Math.round(item2.geometricBounds[2]-item2.geometricBounds[0]);
try{
if((myWidth1 == myWidth2) && (myHeight1 == myHeight2)){
alert("Only One Same Size Item to Be Selected!, Please Always Select Different Size Items!", "Info!");
app.selection[0].select(SelectionOptions.REMOVE_FROM);
}else{
alert("Your Selected items is Different Size Items!", "Info!");
}
}catch(e){
}I know i can collect all selected items but i dont know if i can compare them at once!, actually im not sure if this is possible with javascript?, in this exmaple i collect all widths and heigt but i cant figure how to comapre them and deselect all the matches!, im stucked here and thanks in advance for any help or advice
for (var i = 0; i < app.selection.length; i++) {
var mySelection = app.activeDocument.selection[i].geometricBounds;
var myWidth = Math.round(mySelection[3]-mySelection[1]);
var myHeight = Math.round(mySelection[2]-mySelection[0]);
}
