Skip to main content
May 19, 2015
Answered

Having trouble with a script selecting elements that are part of an envelope distort.

  • May 19, 2015
  • 1 reply
  • 1638 views

Hello, first time posting I hope I'm doing this correctly.

Basically, I have a file that requires a text change which is then exported and edited in Photoshop. I recently have started experimenting with Envelope Distorts as it offered me better control over the span of my documents text areas, however when I run my script on the document, it fails to catch any text that is wrapped with an Envelope Distort. I'm assuming it's because the script is searching for textFrames and when part of an Envelope Distort text becomes something else.

Thanks!

This topic has been closed for replies.
Correct answer Qwertyfly___

Oh yes, I forgot one more step of pain for search/replacing the text XML file to update a document in the way I started describing above: the text content would need to be parsed for and then encoded with, an XML string function to make sure special characters are taken care of.


Ok, this should do the trick...

Break it and re-make it!

var sel = app.activeDocument.selection;

app.executeMenuCommand ('Release Envelope');

var sel2 = app.activeDocument.selection;

for(var i = 0; i < sel2.length; i++){

  if(sel2.typename == "TextFrame"){

      sel2.contents = "new text for envelope";

  }

}

app.executeMenuCommand ('Make Envelope');

1 reply

Silly-V
Legend
May 19, 2015

Yes, those text frames will be now part of the envelope distort "PluginItem", and I see that the inner text is no longer accessible by script. Maybe you can find a way to apply the envelope distort to text after changing the text content.

Qwertyfly___
Legend
May 20, 2015

if you enter isolation mode on the envelope then the text become visible and editable.

you could play with:

app.executeMenuCommand('enterFocus');

app.executeMenuCommand('exitFocus');


but I could not get the above to work.


another option is to have an action to "Toggle Edit Contents"

Qwertyfly___
Legend
May 20, 2015

Got it...

app.executeMenuCommand ('Edit Envelope Contents');