Copy link to clipboard
Copied
Hi guys, i just want to ask how to change the position of the layer to top left in the art board using script. I have a code here that i found through searching but it will only change the position to the center of the art board and i tried changing it to make the position to top left but i cant seem to make it right. can you guys please help me. it would be a huge help, The code is below.
with (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 i = 0; i < layers.length; i++) {
for (var j = 0; j < layers.pageItems.length;j++) {
layers.pageItems
}
}
}
If the rulerOrigin works and makes your top-left of the artboard at [0,0] then without translation it may be possible to simply set the position of the art to the coordinates explicitly:
layers.pageItems
layers.pageItems
Try to see what this would do?
Copy link to clipboard
Copied
If the rulerOrigin works and makes your top-left of the artboard at [0,0] then without translation it may be possible to simply set the position of the art to the coordinates explicitly:
layers.pageItems
layers.pageItems
Try to see what this would do?
Copy link to clipboard
Copied
thanks! that helps me a lot. do you also know how to make the layers but not the page items to be position to top left i tried this but it wont work. sorry i'm new to javascript.
for(i = 0; i < layers.length; i++){
layers.top = 0;
layers.left = 0;
}
Copy link to clipboard
Copied
layers are containers, there's no position for them. You position the items inside layers.
Copy link to clipboard
Copied
okay, thanks a lot.
Copy link to clipboard
Copied
Bonjour à tous,
Si j'ai bien compris la demande de https://forums.adobe.com/people/john+jayd21181923
ce script devrait convenir.
var docRef = app.activeDocument;
with (docRef) {
var rect = artboards[0].artboardRect;
var docVB = visibleBounds;
var transX = rect[0]-docVB[0];
var transY = rect[1]-docVB[1];
for (var j = 0; j < pageItems.length;j++) {
pageItems
.translate(transX,transY); }
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now