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

[SCRIPT] Move Story vs Cut and Paste

Enthusiast ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Why if I get a story and try to

 

myStory.move(LocationOptions.AT_END , myIP);

 

Where myStory is all contents of a text frame and myIP is an insertion point in another story.
But when I try this, some paragraphs loose their formatting.

 

If I select the story, cut it, select the insertion point, and then paste, like this:

 

app.cut();
app.paste();

 

It works. Am I missing something?

What if I don't have the document visible?

TOPICS
Scripting

Views

527

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

correct answers 1 Correct answer

Community Expert , Mar 11, 2021 Mar 11, 2021

Looked into your document.

What is the story you like to move?
Where is the insertion point?

 

With this example I can see your issue:

var mainStory = app.documents[0].textFrames[0].parentStory;
var storyToMove = mainStory.textFrames[0].parentStory;
var targetInsertionPoint = mainStory.textFrames[0].parent.insertionPoints[0];

storyToMove.move( LocationOptions.AT_END , targetInsertionPoint );

 

Before running the script:

BeforeRunningTheScript.PNG

After running the script the paragraph once starting with "e)" changed its

...

Votes

Translate

Translate
Community Expert ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

I'm surprised anything at all happens: AT_ENT should be AT_END

But, seriously, maybe try .AFTER when you place relative to an insertion point.

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
Enthusiast ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Misstyped, Mr. Kahrel.

.AFTER do not work at all.

Just changes the unformatted paragraph from the first to the last one.

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 Expert ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

Hi lf.corullon,

can you make a sample document available for download where you see this behavior?
Just one page with two text frames not threaded.

 

Thanks,
Uwe Laubender

( ACP )

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
Enthusiast ,
Mar 10, 2021 Mar 10, 2021

Copy link to clipboard

Copied

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 Expert ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Looked into your document.

What is the story you like to move?
Where is the insertion point?

 

With this example I can see your issue:

var mainStory = app.documents[0].textFrames[0].parentStory;
var storyToMove = mainStory.textFrames[0].parentStory;
var targetInsertionPoint = mainStory.textFrames[0].parent.insertionPoints[0];

storyToMove.move( LocationOptions.AT_END , targetInsertionPoint );

 

Before running the script:

BeforeRunningTheScript.PNG

After running the script the paragraph once starting with "e)" changed its formatting:

ResultOfScript.PNG

 

The reason is clear. You need a paragraph return at the end of the story you like to move.

Otherwise InDesign picks up the formatting from the recieving text.

 

Now when a paragraph return is added:

 

ParagraphReturnAtEndOfStoryToMove.PNG

 

The script works as expected:

ParagraphReturnAtEndOfStoryToMove-Result.PNG

 

Regards,
Uwe Laubender

( ACP )

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
Enthusiast ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

LATEST

Perfect, Uwe! Thank you so much.

I can't understand the behavior, but OK. If it works this way, it works this way.

Thank you for the clear explanation, as always!

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