Copy link to clipboard
Copied
I've hit a brick wall with this now, I'm just trying to add some text top-left of Artboard[0] on the active document. It works but ONLY if the artboard is the original one when the document was created, if you go into Artboard mode, move it, and run the script again, the new text layer just ends up in the middle of the canvas.
Could anyone guide me to how can I make it be in the top-left of Artboard[0], so its useful for previously made documents?
!
// make new layer
var myDocument = app.activeDocument;
var myLayer = myDocument.layers.add();
myLayer.name = "Doc Title";
// add a new text frame
var myLabel = myDocument.textFrames.add();
myLabel.contents = app.activeDocument.name;
myLabel.textRange.characterAttributes.size = 7;
Thanks in advance
Copy link to clipboard
Copied
That should help you out
alert (aDoc.rulerOrigin);
alert (aDoc.pageOrigin);
alert (aDoc.artboards[0].rulerOrigin);
alert (aDoc.artboards[0].artboardRect);
Have fun
Copy link to clipboard
Copied
Salut !
Comme le dit pixxel schubser très important (origine globale)
var dec = 5;
var ep = 4;
var myDocument = app.activeDocument;
var ab = myDocument.artboards[0];
var rect = ab.artboardRect;
var myLayer = myDocument.layers.add();
myLayer.name = "titre de Doc";
// Ajouter un nouveau bloc de texte
var myLabel = myLayer.textFrames.add();
myLabel.contents = myDocument.name+'.ai';
myLabel.textRange.characterAttributes.size = 7;
myLabel.position = [rect[0]+dec, rect[1]-dec];
// ajouter le contour de artboards[0]
var width = rect[2]-rect[0];
var height = rect[1]-rect[3];
var cadre = myDocument.pathItems.rectangle(rect[1],rect[0],width,height);
cadre.resize((1-ep/width)*100,(1-ep/height)*100);
cadre.filled = false; cadre.stroked = true; cadre.strokeWidth = ep;
cadre.opacity = 30;
de elleere
Find more inspiration, events, and resources on the new Adobe Community
Explore Now