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.
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.
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.
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
Copy link to clipboard
Copied
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.
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:
subtitle: I. subtitle
Body text.... body text...body text.
subtitle: A. new subtitle
Body text.... body text...body text.
subtitle: 1. new subtitle
Body text.... body text...body text.
subtitle: a. new subtitle
Body text.... body text...body text.
subtitle: 1) new subtitle
Body text.... body text...body text.
subtitle: a) new subtitle
Body text.... body text...body text.
subtitle: (1) new subtitle
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.