🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
6 messages
6 total messages Started by Joerg_Koch Tue, 24 Feb 2009 14:43
Array of Text Objects changes when content of Elements is changed
#958
Author: Joerg_Koch
Date: Tue, 24 Feb 2009 14:43
13 lines
1575 bytes
Hello

I have a script that finds an array of text objects (via grep) that get analysed. When I change the contents of one of the Text Objects in the Array, the following Objects loose their "connection" to the Story Text they are in. The reference is changed by the amount an prior object's content was altered in length. When I walk through the array backwards everything is fine but as I want to expose some of the changes to the user for confirmation I'd like to do it in the order they appear in the text.

Technically
array consists of text objects, found by a regex search
changing one array element after another shifts array reference of all subsequent array elements

I need a way to prevent from that shift. But I can't find a method to change a text objects refernce information. Also I don't find a way how to create a new text object when all I have is it's start position and length relative to the parent story which would be an alternative too...

Any Ideas?

All the best, Joerg
Re: Array of Text Objects changes when content of Elements is changed
#959
Author: Joerg_Koch
Date: Tue, 24 Feb 2009 14:46
1 lines
658 bytes
Sorry, I forgot to add that this is on CS3
Re: Array of Text Objects changes when content of Elements is changed
#969
Author: Olav_Kvern
Date: Tue, 24 Feb 2009 19:36
9 lines
1018 bytes
Hi Joerg,

The only way to avoid iterating backwards through the results is to re-do your search after each change, searching the text from each change to the end of the story.

By the way--a straight JavaScript RegExp search won't give you an array of text objects, it'll give you an array of strings. Did you meant that you were using InDesign's findGrep method?

Thanks,

Ole
Re: Array of Text Objects changes when content of Elements is changed
#977
Author: Joerg_Koch
Date: Tue, 24 Feb 2009 23:43
3 lines
996 bytes
Hi Ole, thanks for the information. Yes, I did use the findGrep method. Sorry for confusion here. Anyway, bad news, I was always done with the script I did and now I'll have to rewrite it. Is there really no method to redefine textobjects or to define new ones when you know where they should start and end in the parent story?

Thanks, Joerg
Re: Array of Text Objects changes when content of Elements is changed
#979
Author: Olav_Kvern
Date: Wed, 25 Feb 2009 00:28
7 lines
1016 bytes
Hi Joerg,

InDesign keeps track of text objects based on their index from the start of the story. The fragility of the objects really depends on the object and on the amount of text you're adding/removing. There are plenty of ways to try to maintain/re-acquire text references after removing/adding text before them, but they're all a lot more work than the approach I suggested.

Thanks,

Ole
Re: Array of Text Objects changes when content of Elements is changed
#991
Author: Joerg_Koch
Date: Wed, 25 Feb 2009 09:33
7 lines
1089 bytes
Hi Ole

Thanks again. The search script I did is quite complicated (multiple searches with the results collected in one array and then compared with each other), so at the moment I think it would be worth a try to redefine the text objects for me.

And I would be curious how to put up a text object too. So any hint how to set up one would be very welcome. Even though what you write sounds reasonable :-)

Thanks for your Help, Joerg
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads