references, InDesign text ranges, and sloooow scripts
references, InDesign text ranges, and sloooow scripts
- Subject: references, InDesign text ranges, and sloooow scripts
- From: Courtney Schwartz <email@hidden>
- Date: Wed, 17 Nov 2004 19:34:41 -0500
So I've come to ask the opinion of anyone much smarter than me... :)
I am looking to get a list of text that has a certain paragraph style. Simple enough when I run a "search with find attributes {applied paragraph style: "Chapter"} ". But then the trouble begins.
You see, I need to get two things from those results: 1) every word after the first word (the rest of the list), and 2) the page that the text range occurs on (the parent of the parent text frame).
But this is a really *large* document. Although everything I've tested regarding this works on smaller docs, they completely poops themselves when I try to use them on this document. So the character list (that appears to comprise part of the text range class), like:
text from character 251161 to character 251182 of story id 837 of document "longDoc.indd"
which is returned from that search makes things really slow, really fast. In fact, the first found item returns results almost immediately, but by the fourth found item, the script times out. It seems like every time I try to use this text range (including to set a reference to it to speed things up), InDesign is counting its way through the characters until it gets to the proper index... which, at the 251,161th character, is a really freaking long time.
I *think* that my solution is to somehow use references to the list of characters rather than the text range itself. But every time I try to get those character ranges to set my variable, my script times out...
So somehow, I am doing it wrong... every way I've tried. :) I can't figure out a way to get at these character ranges to set a reference without timing out.
Can someone help me out? How do I get those character object references? More importantly, how do I get them quickly?
Code snippet follows...
Thanks,
Courtney Schwartz
<x-tad-smaller>tell</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>application</x-tad-smaller><x-tad-smaller> "InDesign CS"
</x-tad-smaller><x-tad-smaller>set</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>properties</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> {</x-tad-smaller><x-tad-smaller>find preferences</x-tad-smaller><x-tad-smaller>:</x-tad-smaller><x-tad-smaller>nothing</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>change preferences</x-tad-smaller><x-tad-smaller>:</x-tad-smaller><x-tad-smaller>nothing</x-tad-smaller><x-tad-smaller>}
</x-tad-smaller><x-tad-smaller>tell</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>active document</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>set</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>theTextRangeList</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> (</x-tad-smaller><x-tad-smaller>search</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>with find attributes</x-tad-smaller><x-tad-smaller> {</x-tad-smaller><x-tad-smaller>applied paragraph style</x-tad-smaller><x-tad-smaller>:"Chapter"})
</x-tad-smaller><x-tad-smaller>select</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>item</x-tad-smaller><x-tad-smaller> 1 </x-tad-smaller><x-tad-smaller>of</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>theTextRangeList</x-tad-smaller><x-tad-smaller> --</x-tad-smaller> This would time out if it were item 4 or greater. The Event Log shows this as retrieving something like "text from character 251,161 to character 251,182 of story id 837 of document "longDoc.indd"", and the time of the retrieval makes it seem like it's counting it's way up to 251,161...<x-tad-smaller>
</x-tad-smaller><x-tad-smaller>end</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>tell</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>set</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>properties</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> {</x-tad-smaller><x-tad-smaller>find preferences</x-tad-smaller><x-tad-smaller>:</x-tad-smaller><x-tad-smaller>nothing</x-tad-smaller><x-tad-smaller>, </x-tad-smaller><x-tad-smaller>change preferences</x-tad-smaller><x-tad-smaller>:</x-tad-smaller><x-tad-smaller>nothing</x-tad-smaller><x-tad-smaller>}
</x-tad-smaller><x-tad-smaller>end</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>tell</x-tad-smaller> _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden