Trying to Adjust Items in One Side by Item Type Selected
Dear Experts, i wrote simple scripts to move items (six types of them) 3mm in vertical direction , it work fine with no conditions in page or spread but when i decide to move the items in even or odd pages by selection it ignore the logical operator (OR) and move all the items in the all pages (even or odd) !, this is strange or maybe i did somethig wrong or miss something, because it shouid only move the same selected item type only not all items!, i used (OR) ! , here is the code :
//MySelection Items Adjuster -- Odd or Even Pages
function MySelectionAdjuster() {
var mySelection = app.selection;
var allDocPages = app.documents[0].pages.everyItem().getElements();
// Loop all pages:
for (var n = 0; n < allDocPages.length; n++) {
// Test Left or Right Hand side of page:
//if (allDocPages[n].side == PageSideOptions.LEFT_HAND) { //Left (Odd)
if (allDocPages[n].side == PageSideOptions.RIGHT_HAND) { //Right (Even)
// Get all items on the current page:
var mySelection = allDocPages[n].allPageItems;
for (var i = 0; i < mySelection.length; i++) {
if (mySelection[i].constructor.name == "TextFrame" ||
mySelection[i].constructor.name == "Rectangle" ||
mySelection[i].constructor.name == "Oval" ||
mySelection[i].constructor.name == "Polygon" ||
mySelection[i].constructor.name == "Group" ||
mySelection[i].constructor.name == "GraphicLine"
) {
var mySelected = mySelection[i];
mySelected.move(undefined , [0 ,"3mm"]);
}
}
}
}
alert("Amount of "+mySelection.length+" items Moved!","Finished" );
}
app.doScript(MySelectionAdjuster, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Move Selected Items");
so please help to identify the script logic problem, and thanks in advance
