Hi! This shouldn´t be a question but a post about a short script I worked on for a week (the destiny of each newbee). It works in larger documents. Of course there is a need for a library and its elements, special kind of items the script searches for and an open document with some pages. I´m sure there are many other ways to make the script more short and with higher performance. Feel free to leave your opinion... var myDoc = app.activeDocument; var myObj = myDoc.selection[0]; var myPages = myDoc.pages.everyItem(); var numberOfPages = myDoc.pages.length; var lastPgNumber = myDoc.pages.lastItem().name; var newLabel; var myNewLabel; var myGroups = myDoc.groups; var allMyGroups = myGroups.length; var allMyObjects; var myPageNumber; var oldObjPgNr; var myObjects = [], badObj = [], myText = [], myRectPositionY1 = [], myRectPositionX1 = [] newPagesArray = []; app.doScript(deleteObj, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Preislabel ändern"); function deleteObj() { for (var i=0; i < allMyGroups; i++) { var thisGroup = myGroups; //selecting groups (I only need the groups ON pages, with TWO items inside, one of the items should be a RECTANGLE) ... if (thisGroup.parentPage != null && thisGroup.pageItems.length == 2 && thisGroup.allPageItems[1].constructor.name == "Rectangle") { // ... in addition: the rectangle should be WHITE if(thisGroup.rectangles[0].fillColor.name == "Paper") { // add all "useful" groups in an ARRAY myObjects.push(thisGroup); } } //else if (badObj.push(thisGroup)); } allMyObjects = myObjects.length; for(var n=0; n < allMyObjects; n++){ // calculate the "real" PAGE-NUMBER oldObjPgNr = myObjects .parentPage.name; myPageNumber = numberOfPages - (lastPgNumber - oldObjPgNr)-1; // get coordinates for the current object myRectPositionY1.push(myObjects .geometricBounds[1]+ 6); myRectPositionX1.push(myObjects .geometricBounds[0] ); // grab new object from ibrary newLabel = app.libraries.itemByName("SF_Kataloge_Zutaten.indl").assets.itemByName("SF_Preis_rot_NEU"); myNewLabel = newLabel.placeAsset(myDoc); // move new object to the same page and location like the current object myNewLabel[0].move(myDoc.pages[myPageNumber]); myNewLabel[0].move([myRectPositionY1 , myRectPositionX1 ]) // replace contents of the new object with the contents of the current object myNewLabel[0].contents = myObjects .textFrames[0].contents; } for(var b=0; b < allMyObjects; b++){ // delete all groups myObjects.remove(); } } Regards A. ps. It shouldn´t be forgetted: of course I had a lot of help from the community here!!! Thank you by the way!
... View more