Copy link to clipboard
Copied
Hi, Im looking for a simple script which will check the dimensions of an artboard and populate a selected text frame with the size. It would be great if you was working to a scale and you could select the scale option and then the script calculates the dimensions and adds this to the text frame. (I guess thats two parts).
Anyone know of a script that can do this.? I have found a great script which you can select an object and then apply the script to add mark up with a scale option, but I just want to add a simple string to a text frame.
can anyone help?
lister
Select only one text frame and execute this script.
Then the active artboard size is populated in the selected text frame.
Like this?
...(function () {
var doc,
sel,
rect,
w,
h,
unitType = "";
if (app.documents.length === 0) {
alert("Open Document.");
return;
}
doc = app.activeDocument;
sel = doc.selection;
if (sel.length !== 1) {
alert("Select only one TextFrameItem.");
return;
}
if (!sel[0].constructor
Copy link to clipboard
Copied
Select only one text frame and execute this script.
Then the active artboard size is populated in the selected text frame.
Like this?
(function () {
var doc,
sel,
rect,
w,
h,
unitType = "";
if (app.documents.length === 0) {
alert("Open Document.");
return;
}
doc = app.activeDocument;
sel = doc.selection;
if (sel.length !== 1) {
alert("Select only one TextFrameItem.");
return;
}
if (!sel[0].constructor.name === "TextFrameItem") {
alert("Select only one TextFrameItem.");
return;
}
switch (doc.rulerUnits) {
case RulerUnits.Centimeters:
unitType = "cm";
break;
case RulerUnits.Inches:
unitType = "in";
break;
case RulerUnits.Millimeters:
unitType = "mm";
break;
case RulerUnits.Picas:
unitType = "pc";
break;
case RulerUnits.Points:
unitType = "pt";
break;
case RulerUnits.Pixels:
unitType = "px";
break;
default:
return;
}
rect = doc.artboards[doc.artboards.getActiveArtboardIndex()].artboardRect;
w = Math.round(Number(new UnitValue(rect[2] - rect[0], "pt").as(unitType)) * 100) / 100;
h = Math.round(Number(new UnitValue(rect[1] - rect[3], "pt").as(unitType)) * 100) / 100;
sel[0].contents = "" + w + unitType + ", " + h + unitType;
}());