Copy link to clipboard
Copied
var labelPath = grp.pathItems.rectangle(10, 0, 100, 20);
var labelText = grp.textFrames.areaText(labelPath);
labelText.contents = "label text";
labelText.name = "label";
Copy link to clipboard
Copied
check this thread for a possible solution
https://community.adobe.com/t5/illustrator-discussions/vertical-alignment-scripting/td-p/12395365
Copy link to clipboard
Copied
to add to this, here is the function I have been using. allows input for changing to whichever type of alignment. so you can do
/*
Align Area Text Function
aligns an area frame based on an input value, 0=Top, 1=Center, 2=Bottom, 3=Justify
other action string information
The first name is the set name, in a hex based code, first number is number of characters to decode and the second string is the name converted to hex
the second name below actioncount and action, is the action name, same numbers apply, first is character length and second is name converted to hex
*/
function AlignAreaText(TextFrameToAlign, AlignNumber) {
var ActionString = [
'/version 3',
'/name [ 12',
'416c69676e54657874536574',
']',
'/isOpen 1',
'/actionCount 1',
'/action-1 {',
'/name [ 9',
'416c69676e54657874',
']',
'/keyIndex 0',
'/colorIndex 0',
'/isOpen 1',
'/eventCount 1',
'/event-1 {',
'/useRulersIn1stQuadrant 0',
'/internalName (adobe_frameAlignment)',
'/localizedName [ 24',
'417265612054657874204672616d65416c69676e6d656e74',
']',
'/isOpen 0',
'/isOn 1',
'/hasDialog 0',
'/parameterCount 1',
'/parameter-1 {',
'/key 1717660782',
'/showInPalette 4294967295',
'/type (integer)',
'/value ' + AlignNumber,
'}',
'}',
'}'].join("\n")
var f = File(Folder.desktop+"/VerticalTextAlign.aia");
f.open('w');
try {
f.write(ActionString);
} catch (e) {/*alert(e.message)*/}
f.close();
app.executeMenuCommand("deselectall")
TextFrameToAlign.selected = true;
app.loadAction(f);
app.doScript('AlignText', 'AlignTextSet');
try {
app.unloadAction('AlignTextSet', '');
} catch (e) {/*alert(e.message)*/}
f.remove();
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now