Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Text Top-Left Of Artboard only works if Artboard hasn't moved

Community Beginner ,
Nov 15, 2018 Nov 15, 2018

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

TOPICS
Scripting
269
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Nov 15, 2018 Nov 15, 2018

That should help you out

alert (aDoc.rulerOrigin);

alert (aDoc.pageOrigin);

alert (aDoc.artboards[0].rulerOrigin);

alert (aDoc.artboards[0].artboardRect);

Have fun

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 15, 2018 Nov 15, 2018
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines