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

Problem adding an anchored text frame into a duplicated paragraph

New Here ,
Jan 26, 2017 Jan 26, 2017

Copy link to clipboard

Copied

Hi,

I don't understand in which paragraph my new text frame is added,

Here is my code:

function buildFrameBox(para)

{

     var copyPara = para.duplicate(LocationOptions.AFTER, para),

     frame;

     $.writeln(para.textFrames.length + ':' + copyPara.textFrames.length); // 0:0

     app.findGrepPreferences = NothingEnum.NOTHING;

     app.changeGrepPreferences = NothingEnum.NOTHING;

     app.findGrepPreferences.findWhat = "[^\r]"; // Remove anchor character

     app.changeGrepPreferences.changeTo = '';

     copyPara.changeGrep(); // Remove all content in my new paragraph except line break

     frame = copyPara.insertionPoints.firstItem().textFrames.add();

     frame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_AND_WIDTH_PROPORTIONALLY;

     frame.contents = 'Some text here';

     $.writeln(para.textFrames.length + ':' + copyPara.textFrames.length); // 1:0

     return frame;

}

The question is: If I am adding a text frame into the duplicated paragraph, why does it say that original paragraph contains a text frame while the duplicated has no frames at all?

In my InDesign document script works fine and text frame is placed where I want.

Thanks in advance for your help.

TOPICS
Scripting

Views

276

Translate

Translate

Report

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 Expert ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

> In my InDesign document script works fine and text frame is placed where I want.

If your script works fine, what's the problem?

Anyway, this line:

app.findGrepPreferences.findWhat = "[^\r]";

matches anything that's not a \r. Maybe that's the problem.

Votes

Translate

Translate

Report

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
New Here ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

Hi,

Thanks for your reply.

What I am trying to do is to create a textFrame where some paragraphs should be moved into.Also, I need to be careful when moving paragraphs that already contain textFrames.

After the code quoted above, I want to move my original paragraph into that textFrame.

So, the textFrame is created as expected.

The problem is that the original paragraph contained 0 textFrames and after that code is run it contains 1 textFrame.

But I expected original paragraph to contain 0 textFrames and the copy paragraph to contain 1.

So I am wondering if there is any problem with InDesign DOM.

The grep code is what I want so in my doc I got:

     ...

     Original Paragraph \r

     Text Frame \r

     ...

Thanks a lot for having a look into it.

Votes

Translate

Translate

Report

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
People's Champ ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

app.findGrepPreferences.findWhat = "[^\r]";

matches anything that's not a \r. Maybe that's the problem.

Well technically it would match anything that's not the "r" character

Votes

Translate

Translate

Report

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
New Here ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

LATEST

Yes,
Sorry, that line was wrong
.

It should be:

app.findGrepPreferences.findWhat = "[^\\r]"; // Remove everything except \r

However the problem/question about the number of textFrames in original paragraph remains.

Thanks a lot for your reply.

Votes

Translate

Translate

Report

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 ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

Hello!

My name is Dumitru.

I work on design on books, and thus trying for a while to compose a GREP for subtitles to ease mai work load, but no success.


I have the Paragraph Styles and I can do the Character Styles for these subtitles with no dot “.“ at the end of them, of course.

I believe all my best was: ^[\(\u+\l+\d]\.\)+r but it did not work. At least I figured I need one GREP for each subtitle, because my subtitles are all different!

Examples of what subtitles I need is this:

  • Body text.... body text...body text...

          subtitle: I. subtitle

         Body text.... body text...body text.

  • Body text.... body text...body text...

          subtitle: A. new subtitle

         Body text.... body text...body text.

  • Body text.... body text...body text

          subtitle: 1. new subtitle

         Body text.... body text...body text.

  • Body text.... body text...body text

          subtitle: a. new subtitle

         Body text.... body text...body text.

  • Body text.... body text...body text

          subtitle: 1) new subtitle

         Body text.... body text...body text.

  • Body text.... body text...body text

          subtitle: a) new subtitle

         Body text.... body text...body text.

  • Body text.... body text...body text

          subtitle: (1) new subtitle

         Body text.... body text...body text.

  • Body text.... body text...body text

          subtitle: (a) new subtitle

         Body text.... body text...body text.

I felt I am close but I just could not make it. So, I said I will ask people who really know this wonderful function of InDesign otherwise, GREP.

Thank you.

Votes

Translate

Translate

Report

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