How do I script a new position for an entire layer?
I have an 8x10 template but the artboard needs to be larger than the template's page size. I can open the template and resize the artboard to the larger size but the contents of the original template still need to be centered on the new artboard. The artboard is the right position, all of the original template's objects need to be repositioned.
With the GUI it's easy, just select the entire layer with the template contents and enter a new x,y position. In Javascript there is no position setting for an entire layer as a single unit.
Other alternatives I've tried:
- Create a new doc with the right size and use groupItems.createFromFile() for the template - centers the template: strips off the names of all objects and basically makes a hash of the original template. No good since I need those path and group names intact. Why couldn't it just work like Corel's import?
- Create a new doc, open the template, use copy and paste to copy template layers into the new document. Slow and uses up lots of memory. It works ok if there's a border around the template page that makes the centering work.It also works for multiple layers and centers the contents of all layers as a single unit.
One thing I can think of is that groupItems can be positioned so I could put everything in the layer into a single group and move that new group and then move everything back out of the group. This doesn't work for multiple layers unless I want to merge them (which I don't).
Any other suggestions on positioning the contents of one or more layers to be centered on the page? Multiple layers would need to keep their original relative positions.
