Copy link to clipboard
Copied
Hi,
Using Javascript, how to set the ruler origin to top left canvas corner point?
What is the official name for the area outside an artboard? Is it canvas, workspace, workarea, pastboard, ...?
Where is located it in the DOM?
Thank you.
I don't know if it's official (it's not in my Using Adobe Illustrator guide), but I've seen it called pasteboard. As it happens, I believe @CarlosCanto answered the same question yesterday. See here.
Copy link to clipboard
Copied
I don't know if it's official (it's not in my Using Adobe Illustrator guide), but I've seen it called pasteboard. As it happens, I believe @CarlosCanto answered the same question yesterday. See here.
Copy link to clipboard
Copied
Thank you for sharing this info. This was very usefull.
I did some small adjustments. Below my working code...
var myDoc = app.activeDocument;
var dim = getLargestBounds();
myDoc.rulerOrigin = [dim[0],dim[1]+myDoc.height];
function getLargestBounds() {
var tempLayer, tempText, left, top, LARGEST_SIZE = 16383;
tempLayer = app.activeDocument.layers.add();
tempText = tempLayer.textFrames.add();
left = tempText.matrix.mValueTX;
top = tempText.matrix.mValueTY;
tempLayer.remove();
var dimensions = [left, top, left + LARGEST_SIZE, top + LARGEST_SIZE ];
return dimensions;
}
Copy link to clipboard
Copied
Bonjour,
myDoc.rulerOrigin = [dim[0],dim[1]+myDoc.height];
Cette ligne donne un bon résultat uniquement si le plan de travail 0 (artBoard) est dans sa position initiale.
Essayer de le déplacer et relancez le script, vous constaterez que la position de l'origine n'est pas à l'endroit souhaité.
Dans quel but voulez vous placer l'origine des règles à cet endroit ?
René
Copy link to clipboard
Copied
I'm going to jump in here and say I'd like to be able to set the origin [0,0] to any point I select. Repeatedly, in the same doc. I'm not a good scripter and gave up on this some time ago. It would run once, then not again until I quit Illy - not a solution!
Copy link to clipboard
Copied
Hi Met1
Sélectionnez un point sur un tracé existant.
// JavaScript Document for Illustrator
// De elleere
function main() {
if (!selection.length) {return;}
if (selection[0].typename != "PathItem") {return;}
var idoc = app.activeDocument;
var item = selection[0];
var ptSel = item.selectedPathPoints;
var r, pt;
for (var i = 0; i < ptSel.length; i++) {
var pt = ptSel[i];
if (pt.selected == PathPointSelection.ANCHORPOINT) {
r = i;
break;
}
}
if (r != undefined) {
idoc.rulerOrigin = [0,0];
idoc.rulerOrigin = pt.anchor;
}
else {beep();}
}
if (app.documents.length) main();
de elleere, pour vous servir...
Copy link to clipboard
Copied
Sorry René, just realised (I pointed someone else to this script) that I never thanked you - It works great, I'm using it daily, Thanks!
Copy link to clipboard
Copied
Hi met1,
Merci pour le retour...
Copy link to clipboard
Copied
Hi René,
Thank you for bringing up the issue with the moved artboards. This seems to fix it ...
setRuler2canvas();
function setRuler2canvas(){
if(app.documents.length > 0){
var myDoc = app.activeDocument;
myDoc.rulerOrigin = [0,0];
var dim = getLargestBounds();
myDoc.rulerOrigin = [dim[0],dim[1]];
}
}
function getLargestBounds() {
var tempLayer, tempText, left, top, LARGEST_SIZE = 16383;
tempLayer = app.activeDocument.layers.add();
tempText = tempLayer.textFrames.add();
left = tempText.matrix.mValueTX;
top = tempText.matrix.mValueTY;
tempLayer.remove();
var dimensions = [left, top, left + LARGEST_SIZE, top + LARGEST_SIZE ];
return dimensions;
}
Copy link to clipboard
Copied
Bonjour tmmls,
Trés bien, cela fonctionne maintenant, mais vous n'avez pas répondu à ma question.
Dans quel but voulez vous placer l'origine des règles à cet endroit ?
René