Answered
Creating different alignment
How can we set a text frame contents to vertical alignment center using script?
How can we set a text frame contents to vertical alignment center using script?
Thanks @Kurt Gold you have hit the nail on the head!
@SA8888, here is a script that incorporates Kurt's action. Give it a try. I found the technique of saving the action file posted to the forum by @Charu Rajput. Thanks Charu!
- Mark
/**
* Center text in selected text frame vertically.
* @discussion https://community.adobe.com/t5/illustrator-discussions/creating-different-alignment/m-p/13131693
*/
// selection should be a text frame
centerSelectionVertically();
/**
* Create and execute "Center vertically"
* action on the selection.
* @author KurtGold created this action.
*/
function centerSelectionVertically() {
var actionString = "/version 3\n" +
"/name [ 29\n" +
" 616c69676e5f747970655f766572746963616c6c795f63656e74726564\n" +
"]\n" +
"/isOpen 1\n" +
"/actionCount 1\n" +
"/action-1 {\n" +
" /name [ 14\n" +
" 766572746963616c5f616c69676e\n" +
" ]\n" +
" /keyIndex 0\n" +
" /colorIndex 0\n" +
" /isOpen 1\n" +
" /eventCount 1\n" +
" /event-1 {\n" +
" /useRulersIn1stQuadrant 0\n" +
" /internalName (adobe_SLOAreaTextDialog)\n" +
" /localizedName [ 20\n" +
" 466cc3a46368656e746578746f7074696f6e656e\n" +
" ]\n" +
" /isOpen 1\n" +
" /isOn 1\n" +
" /hasDialog 0\n" +
" /parameterCount 3\n" +
" /parameter-1 {\n" +
" /key 1952543846\n" +
" /showInPalette 4294967295\n" +
" /type (integer)\n" +
" /value 1\n" +
" }\n" +
" /parameter-2 {\n" +
" /key 1952539754\n" +
" /showInPalette 4294967295\n" +
" /type (integer)\n" +
" /value 2\n" +
" }\n" +
" /parameter-3 {\n" +
" /key 1952541806\n" +
" /showInPalette 4294967295\n" +
" /type (integer)\n" +
" /value 1\n" +
" }\n" +
" }\n" +
"}\n" +
"";
doActionFromString("vertical_align", "align_type_vertically_centred", actionString)
};
/**
* Create and execute an action using
* the parameters supplied. The action
* file will be removed afterwards.
* @author Charu Rajput
* @discussion https://community.adobe.com/t5/illustrator-discussions/quot-duplicate-layer-quot-command-in-script/m-p/13131761
* @param {TextFrame} frame - an Illustrator TextFrame.
*/
function doActionFromString(name, setName, str) {
var tmp = File(Folder.temp + '/' + setName + '.aia');
tmp.open('w');
tmp.write(str);
tmp.close();
app.loadAction(tmp);
app.doScript(name, setName, false);
app.unloadAction(setName, '');
tmp.remove();
};
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.