Copy link to clipboard
Copied
Hello such. I will see a silly question to which I have not found solution
You can change the position of a artboard using javascript?
Something like: it does not work.
app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
abActive = app.activeDocument.artboards[app.activeDocument.artboards.getActiveArtboardIndex()];
alert("abActive: "+abActive+"\n\n"+
"abActive.position[0]: "+abActive.position[0]+"\n\n"+
"abActive.position[1]: "+abActive.position[1]+"\n\n"
)
abActive.position = [500, 1000];
I searched for information and I have not found.
Thank you very much in advance.
a greeting
Hi levi23​,
if I understand you right – you want to move (only) the artboard without the page items?
You have to go the „long way“:
...// artboardMove.jsx
// https://forums.adobe.com/thread/2194906
// change the position of a artboard using javascript?
// regards pixxxelschubser
var aDoc = app.activeDocument;
//var abSrc = aDoc.artboards[0];
var abIdx = aDoc.artboards.getActiveArtboardIndex ();
var abSrc = aDoc.artboards[abIdx];
var moveX = 500;
var moveY = 1000;
var abSrc_L = abSrc.artboardRect[0] + mo
Copy link to clipboard
Copied
Hi levi23​,
if I understand you right – you want to move (only) the artboard without the page items?
You have to go the „long way“:
// artboardMove.jsx
// https://forums.adobe.com/thread/2194906
// change the position of a artboard using javascript?
// regards pixxxelschubser
var aDoc = app.activeDocument;
//var abSrc = aDoc.artboards[0];
var abIdx = aDoc.artboards.getActiveArtboardIndex ();
var abSrc = aDoc.artboards[abIdx];
var moveX = 500;
var moveY = 1000;
var abSrc_L = abSrc.artboardRect[0] + moveX;
var abSrc_T = abSrc.artboardRect[1] - moveY;
var abSrc_R = abSrc.artboardRect[2] + moveX;
var abSrc_B = abSrc.artboardRect[3] - moveY;
abSrc.artboardRect = [abSrc_L, abSrc_T, abSrc_R, abSrc_B];
But be careful. Have always a look to the max artboard size/position.
Have fun
Copy link to clipboard
Copied
First of all many thanks for your answer, but I do not express well ... I meant to move the artboard and its contents. So it is trying to use the position property.
There is that possibility without using rearrange?
Thank you very much again.
Sorry my english. I am spanish.
a greeting.
Copy link to clipboard
Copied
To move all of the elements, you need should be able to just loop through all of the layers and just move them as well. Instead of moving them all individually, this code should group them, use the GroupItem Translate function, and then ungroup them.
// Get a reference to the layers and loop through them
var layers = aDoc.layers;
for( var i = 0, ii = layers.length; i < ii; i++ ) {
// clear any current selection
doc.selection = null;
// select all elements in the current layer and group them
layers.hasSelectedArtwork = true;
app.executeMenuCommand( "group" );
// translate them using the moveX and moveY variables
var curGroup = layers.groupItems[0];
curGroup.translate( moveX, -moveY );
// ungroup them
app.executeMenuCommand( "ungroup" );
}
Good luck!
Copy link to clipboard
Copied
Hi @zertle,
one note: your code works (but executeMenuCommand() is available only in versions Illu CS6+)
For versions Illu CS5 or older you have to loop through all paths and move the paths also. This (old) solution might be work up to a number of 900 -1000 paths at the same speed or faster as executeMenuCommand(). But the old solution will be slower with a number of paths of 1000 and much more slower with a number of paths above 1200 and more.
Regards.
Copy link to clipboard
Copied
Thank you very much for your help
it works great
regards
Copy link to clipboard
Copied
A two-part answer, if only they could each be marked as correct
Copy link to clipboard
Copied
Hi Silly-V​,
yes, only the TO levi23​ can mark the correct answer.
But everyone else can mark a good answer as helpful answer.
Regards
Copy link to clipboard
Copied
It is done. sorry
thanks