Scripting the prep for Envelope Distort
Hi everyone,
I'm attempting to script an Envelop Distort operation (make with top Object) - or atleast as far into it as I can get.
My workflow is :
I have a selected piece of text. To create a rectangle around it I need exact dimensions, so I create outlines of the text. Based on the outline dimensions, I create a rectangle. I Shift select the rectangle so it is on top, then perform my Envelope Distort operation.
Does anyone have a piece of script working that automates this? I'm using Windows, and currently JavaScript. Even if I can't complete the process I'd like to get as deep into it as possible.
What I have so far creates the rectangle. But I'm unable to cause the rectangle to be selected, or get any further into the process.
Here is what I have... any help would be appreciated.
--------------------------------------------------------------------
if ( documents.length > 0 && activeDocument.selection.length > 0) {
mySelection = activeDocument.selection;
if (mySelection[0].typename == "TextFrame") {
var oSelectedText = mySelection[0];
oSelectedText.createOutline();
var oSelectedGroupedText = activeDocument.selection[0];
with (oSelectedGroupedText) {
filled = false;
stroked = true;
strokeColor = new GrayColor();
strokeColor.gray = 100;
strokeWidth = 1;
}
var oPathItem = activeDocument.activeLayer.pathItems.rectangle(oSelectedGroupedText.top, oSelectedGroupedText.left, oSelectedGroupedText.width, oSelectedGroupedText.height);
with (oPathItem) {
filled = false;
stroked = true;
strokeColor = new GrayColor();
strokeColor.gray = 100;
strokeWidth = 1;
selected = true; // Doesn't work
}
}
}
