Skip to main content
Participant
December 27, 2011
Question

Scripting the prep for Envelope Distort

  • December 27, 2011
  • 1 reply
  • 3366 views

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

          }

     }

}

This topic has been closed for replies.

1 reply

Jongware
Community Expert
Community Expert
December 27, 2011

You don't have to "select" stuff to work with in scripts. You already have a 'handle' on it through your variable 'oPathItem'.

Oh alright: in your case it doesn't work because path Items don't have a 'selected' property. I'm not too sure of Illustrator's document model but this may be because a page item -- your path item's parent -- can contain multiple paths; and you cannot select ''a single path" when it does. You can select individual path points but I don't think you'd want that here.

Then again, all this is of no use since you cannot apply your Envelope Distort. Browsing through the documentation, I don't see anything like that so apparently it's not scriptable.

(Warning: For Advanced Scripters Only)

So you need to emulate the effect -- grab each path point of your outlined text, determine its relative position against the entire text object, and use interpolation against the target rectangle to find its new position. Don't forget to include the control points of curved anchors.

Inspiring
December 27, 2011

Yeah, scripting with the ESTK can't acess this stuff ( most likely provided by app plug-in ) using ExtendScript you are only able to get the one step further… I have not tried this but if an action can record the envelope disort then using either AppleScript or VB will get you further… As they can play out actions…

Participant
December 27, 2011

I've read your other forum posts, and have been able to trigger the Envelope Distort Dialog via VBS using javascript.  It at least brings up the dialog, I have to modify an option and click enter. (To be clear, I've created an action that I'm invoking, but I'm in the neighborhood.)

If I could get to the point of having the rectangle I've created selected and on top - I could invoke the dialog via script and be a good part of the way there.

Just for reference, this is pretty important to me.  In the last 2 weeks, I've done this same repetitive process over 300 times under a time pressure.  It doesn't sound like much but at 4 in the morning when I can't see straight, being able to take 20 to 30 seconds of a repetitive process is meaningful.

Any further thoughts on getting that rectangle selected?  It allows me to do it manually obviously, and I don't have to navigate around/through any groupings, etc.  I just am missing a bit of knowledge I think.  I feel like I'm close, but can't touch it even though I can see it.

Thanks in advance,

Dewey

Message was edited by: DeweySchramm  [Clarification]