var box = new Array(x,y+h,w+x,y); this should fix the position, let me know if it still seems out, I did not want to mess with coordinate systems for a simple script. quick run through. x,y,w,h variables are the selection zone. you could get these via script, a dialog, or hard code them if every document has the wanted items in the same location X,Y is the top left corner of the new location EDIT: Bottom Left... but now I'm confusing myself if you want it centered to an object that can be done, but we can do that when I get more info box is just an array of the selection zone (this has just a smige of math, And I stuffed it up...) pos is also just an array, both of these are just preparing the data for use. makes things cleaner. now we clear any selection as we will be working with selected items and don't want to effect other random object that may have been selected before the script was run. now I should be clear that this next section is a little bit of a hack in an effort to reduce the amount of code and make it feel simple and logical. a more correct method would be to loop all objects testing each location, if it falls within the selection zone move it. but as there is a built in function to select everything on an artboard I am making use of that by turning the selection zone into an artboard. so thats the next stage, make an artboard, give it size and pos, name it (just in case script is stopped half way, we can recognize the added artboard with ease) now the built in function to select artboard contents next we group, again I have used a built in command for group, this again could be done with a more pure javascript approach, but this one liner dose the job and makes the code simple to follow now all thats left is to move the selection and delete the temp page. Done. this last stage is where you want to make a few changes. if we give the script X,Y as the center coordinates of the box you want to center to, then if we do a little math to the pos variable we can get our selection centered to the X, and Y, lets keep X,Y both at 0 to start, concider: var sel = doc.selection var Sh = sel[0].height; var Sw = sel[0].width; var pos = new Array(X-(Sw/2),Y+(Sh/2)); try this one... // SELECTION // these are pt values var x = 700; var y = 0; var w = 500; var h = 850; // NEW POSITION var X = 0; var Y = 0; // now put in array var box = new Array(x,y+h,w+x,y); var doc = app.activeDocument; doc.selection = null; var abs = doc.artboards; var newPage = abs.add(box); newPage.name = "temp_page"; doc.selectObjectsOnActiveArtboard(); app.executeMenuCommand ('group') var sel = doc.selection var Sh = sel[0].height; var Sw = sel[0].width; var pos = new Array(X-(Sw/2),Y+(Sh/2)); sel[0].position = pos; newPage.remove(); as for reference material for scripting, I use (and I'll try to keep most used to least) http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/CC/Illustrator%20Scripting%20Reference%… this is the official doc, sorely lacking. then I go to google, this form tends to come up trumps in most searches, but sites like w3 and the like have craploads of info on javascript, as you get used to the illustrator dom you will get a better understanding of the differences between JS for web, and JS run localy. and Use the ESTK. the data browser is a must and it's object model viewer is also very important. to get to where I am I just spent time here in the forums answering questions, if I don't know the answer I look for one. test it out, and post if I can get it to work. this is good real world experience, and gives a great overview of what you can and can't do. I have also met some great folk here in the forums that have been a great source of info, inspiration, and ideas. stick at it, ask any questions you have, and post any snippets you find interesting and/or useful, and in no time you will be churning out little time savers. wow, what a rant, Sorry... EDIT: the coordinate system in this does not seem 100%. I think adding the extra page may change it somehow. I'll think on it, not that I think it will have any detrimental effects, all it need to do is "the correct thing", as long as it does that who cares... LOL
... View more