Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Apply Function Only to Specific Frame

Community Beginner ,
Jun 12, 2015 Jun 12, 2015

Hello everyone!

I have a project in which I duplicate a text frame using the following command

function copypaste() {

var doc = app.activeDocument;

var page = doc.pages[0];

var frame1 = page.textFrames[0];

var frame2 = page.textFrames[1];

frame2.texts.everyItem().select();

app.copy();

frame1.texts.everyItem().select();

app.paste();

}

which leads me to having two text frames with identical content. However, I want one text frame to be formatted from a raw, text form and the other one needs certain words extracted. Think of it like "One is text, the other one is tags for archival purposes", because - to be honest - that's pretty much what it is.

I have all the word-extraction and all the formatting down, because that wasn't so hard. The only thing that I'm completely stumped on is how to direct functions at a certain text frame.

An example: Let's say I want to have the function "applyRedParagraph" only applied to text frame 1 and "extractBlueWords" only applied to text frame 2.

How do I do that?

Thanks for your help!

TOPICS
Scripting
358
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 12, 2015 Jun 12, 2015

Hi Gothamite

Is there a rule which text frames should be what?

One possibility is that you select text frames, then call a JavaScript, select the next few text frames and so on.

kind regards

Daniel (from Switzerland)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 15, 2015 Jun 15, 2015

Daniel Sterchi wrote:

Hi Gothamite

Is there a rule which text frames should be what?

One possibility is that you select text frames, then call a JavaScript, select the next few text frames and so on.

kind regards

Daniel (from Switzerland)

Hi Daniel

No, there's no difference. Let's say I have frame_1 and frame_2. And action_1 and action_2.

It doesn't matter if action_1 is applied to frame_1 or frame_2 as long as the the frame action_1 does not apply to has action_2 applied.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jun 12, 2015 Jun 12, 2015

don't use copy paste. DO NOT!

try something like:

var doc = app.activeDocument;

var page = doc.pages[0];

var frame1 = page.textFrames[0];

var frame2=frame1.duplicate(page);

applyRedParagraph(frame1);

extractBlueWords(frame2);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 17, 2015 Jun 17, 2015
LATEST

if I get that right you choose text frames manually and apply an action_1. All the text frames on which you didn't apply action_1, action_2 has to be applied. Is that correct?

If this is correct one can solve the problem with two little (it depends on what you want to do) JavaScrips. You could select text frames then run JavaScript_1. If all the frames that action_1 should be applied are done, then you can run a second JavaScript that tackles the other action.

kind regards

Daniel (from Switzerland)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines