How do I script a new position for an entire layer?


i have 8x10 template artboard needs larger template's page size. can open template , resize artboard larger size contents of original template still need centered on new artboard. artboard right position, of original template's objects need repositioned.

 

with gui it's easy, select entire layer template contents , enter new x,y position. in javascript there no position setting entire layer single unit.

 

other alternatives i've tried:

 

  1. create new doc right size , use groupitems.createfromfile() template - centers template: strips off names of objects , makes hash of original template. no since need path , group names intact. why couldn't work corel's import?
  2. create new doc, open template, use copy , paste copy template layers new document. slow , uses lots of memory. works ok if there's border around template page makes centering work.it works multiple layers , centers contents of layers single unit.

 

one thing can think of groupitems can positioned put in layer single group , move new group , move out of group. doesn't work multiple layers unless want merge them (which don't).

 

any other suggestions on positioning contents of 1 or more layers centered on page? multiple layers need keep original relative positions.

i may misunderstanding or on simplifying don't need measure center of visual bounds against center of art board translate items same amount? don't have multi-artboards nore can resize use this…

 

#target illustrator  var docref = app.activedocument;  (docref) {      rulerorigin = [0,0];      var docvb = visiblebounds;      var transx = (width / 2) - ((docvb[0] + docvb[2]) / 2);      var transy = (height / 2) - ((docvb[1] + docvb[3]) / 2);      for (var = 0; < pageitems.length; i++) {           pageitems[i].translate(transx, transy, true, true, true, true);      } } 



More discussions in Illustrator Scripting


adobe

Comments

Popular posts from this blog

How to decompile jsxbin to jsx

Gavik Photoslide GK2: Not able to upload photos - Joomla! Forum - community, help and support

Phoca Guestbook logger registret bruger af - Joomla! Forum - community, help and support