Thread View: adobe.scripting.indesign
25 messages
25 total messages
Started by Thomas_Silkjaer
Mon, 16 Mar 2009 21:14
[AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Mon, 16 Mar 2009 21:14
Date: Mon, 16 Mar 2009 21:14
5 lines
882 bytes
882 bytes
I am working on some scripts which interacts a lot with each page of a long InDesign document - basically it does a lot of searching, and does stuff depending on what it finds. For the first couple of minutes, its really fast, but then gets slower and slower. Is there any way to make InDesign catch its breath? Like pausing the script?
Re: [AS] Script runs slower and slower
Author: Shane_Stanley
Date: Mon, 16 Mar 2009 21:39
Date: Mon, 16 Mar 2009 21:39
6 lines
1421 bytes
1421 bytes
The problem is all the undos; you can clear them by periodically doing a 'save as" -- save to the same file path. -- Shane Stanley <sstanley@myriad-com.com.au> AppleScript Pro Sessions <http://scriptingmatters.com/aspro>
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Tue, 17 Mar 2009 07:23
Date: Tue, 17 Mar 2009 07:23
10 lines
932 bytes
932 bytes
Thanks for the tip! Sounds exactly like that could be the issue. Though InDesign pops up this message when i try to save the document to the same file path: Adobe InDesign CS4 got an error: Cannot save �test_4.indd� under a new name. (Error code: 1). I am doing it like this: tell document save to file path end tell
Re: [AS] Script runs slower and slower
Author: Shane_Stanley
Date: Tue, 17 Mar 2009 07:36
Date: Tue, 17 Mar 2009 07:36
7 lines
1392 bytes
1392 bytes
You probably want something like: save document 1 to (get full path of document 1) -- Shane Stanley <sstanley@myriad-com.com.au> AppleScript Pro Sessions <http://scriptingmatters.com/aspro>
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Tue, 17 Mar 2009 08:21
Date: Tue, 17 Mar 2009 08:21
3 lines
695 bytes
695 bytes
Thanks, fixed it.. Found out that "file path" didn't include the document name, "full name" did. Thanks!
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Tue, 17 Mar 2009 11:56
Date: Tue, 17 Mar 2009 11:56
1 lines
736 bytes
736 bytes
I can feel a clear difference from before to now, but still the script runs a little slower and slower. Do you know of any other ways of optimizing?
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Tue, 17 Mar 2009 12:26
Date: Tue, 17 Mar 2009 12:26
1 lines
667 bytes
667 bytes
I fired the script from the script palette in InDesign instead, helped a lot ;)
Re: [AS] Script runs slower and slower
Author: SuperMacGuy
Date: Tue, 17 Mar 2009 14:57
Date: Tue, 17 Mar 2009 14:57
1 lines
1194 bytes
1194 bytes
Without seeing your code it's hard to say what you can optimize. Repeat loops are your first area to target, to make them as fast as possible. There are some very tricky ways to deal with lists in repeats that can yeild amazing results, but need to be studied carefully. Check MacScripter.net for examples. You might also want to try to limit the size of any lists, or try to filter down a list of objects to a shorter list of objects. Or instead of looking at all page items only look at page items of page X.
Re: [AS] Script runs slower and slower
Author: Olav_Kvern
Date: Tue, 17 Mar 2009 16:01
Date: Tue, 17 Mar 2009 16:01
7 lines
854 bytes
854 bytes
Hi Thomas, In InDesign CS4, you can also run your script using the do script method--if you do that, you can turn off undo altogether (or, really, package all of the script actions as a single undo step). Thanks, Ole
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Tue, 17 Mar 2009 19:13
Date: Tue, 17 Mar 2009 19:13
5 lines
1095 bytes
1095 bytes
Thanks for the latest tips as well! I have launched a new InDesign blog where my latest post shows what I accomplished with this script. And I must say, executing a script from the scripting palette in InDesign makes scripts run waaay faster than from the AppleScript editor. What took an hour to run through now is done in minutes. Blog post and video can be seen at <http://indesigning.net/the-power-of-scripting>
Re: [AS] Script runs slower and slower
Author: Shane_Stanley
Date: Tue, 17 Mar 2009 21:42
Date: Tue, 17 Mar 2009 21:42
6 lines
1497 bytes
1497 bytes
The other potential speed booster is to open the document you're working on without a window. just make sure you handle any potential errors. -- Shane Stanley <sstanley@myriad-com.com.au> AppleScript Pro Sessions <http://scriptingmatters.com/aspro>
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Tue, 17 Mar 2009 22:00
Date: Tue, 17 Mar 2009 22:00
1 lines
737 bytes
737 bytes
Would it be the same result as turning redraw off?
Re: [AS] Script runs slower and slower
Author: Olav_Kvern
Date: Tue, 17 Mar 2009 22:13
Date: Tue, 17 Mar 2009 22:13
20 lines
1177 bytes
1177 bytes
Hi Thomas, Here's a general purpose "do script" script--it'll just run a script file you select using the "fast entire script" undo mode: --RunScriptFromFile.applescript --An InDesign CS4 AppleScript -- --Runs a script file using the do script method. set myScriptFile to choose file with prompt "Select an AppleScript" tell application "Adobe InDesign CS4" do script myScriptFile language applescript language undo mode fast entire script undo name (myScriptFile as string) end tell Should be quite a bit faster. Let me know how it works for you! Thanks, Ole
Re: [AS] Script runs slower and slower
Author: Shane_Stanley
Date: Tue, 17 Mar 2009 22:23
Date: Tue, 17 Mar 2009 22:23
11 lines
1573 bytes
1573 bytes
I'm not sure that turning redraw off did anything in CS3; I haven't checked in CS4. I did a rough test with a script that had to draw several hundred transparent ovals. To make it go faster, the script made the layer they were on invisible, so no redraw was needed. Even so, it took maybe 3-4 minutes; doing it without a window took closer to half-a-minute. -- Shane Stanley <sstanley@myriad-com.com.au> AppleScript Pro Sessions <http://scriptingmatters.com/aspro>
Re: [AS] Script runs slower and slower
Author: Shane_Stanley
Date: Tue, 17 Mar 2009 22:34
Date: Tue, 17 Mar 2009 22:34
12 lines
1656 bytes
1656 bytes
On 18/3/09 9:13 AM, "Olav Kvern" <member@adobeforums.com> wrote: > it'll just run a script file you select using the "fast entire script" undo > mode Can you explain the difference between "fast entire script" and "entire script"? It doesn't seem to be documented anywhere. The word fast is enticing, but I fear there are strings attached. -- Shane Stanley <sstanley@myriad-com.com.au> AppleScript Pro Sessions <http://scriptingmatters.com/aspro>
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Wed, 18 Mar 2009 07:17
Date: Wed, 18 Mar 2009 07:17
5 lines
951 bytes
951 bytes
Thanks for all the tips! I will do some more testing when I get to the office again. I tried running the script with redraw off, but didn't take time. Seemed a little faster though. Could you explain how to run a script without a window? I think ill try to run the script with redraw on, off, through a do script and without a window and compare the times.
Re: [AS] Script runs slower and slower
Author: Shane_Stanley
Date: Wed, 18 Mar 2009 07:36
Date: Wed, 18 Mar 2009 07:36
13 lines
1640 bytes
1640 bytes
On 18/3/09 6:17 PM, "Thomas Silkjaer" <member@adobeforums.com> wrote: > Could you explain how to run a script without a window? You have to open it that way. Something like: set theDocument to open fileAlias without showing window -- do your stuff, then open widow with... tell theDocument to make window -- Shane Stanley <sstanley@myriad-com.com.au> AppleScript Pro Sessions <http://scriptingmatters.com/aspro>
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Thu, 19 Mar 2009 08:40
Date: Thu, 19 Mar 2009 08:40
12 lines
1200 bytes
1200 bytes
I did some tests. Running the script with: 1. Using "save as" to flush undo's, with redraw on: 3:28min 2. Using "save as" to flush undo's, with redraw off: 1:55min 3. Using "do script" and don't do "save as", with redraw on: 3:02min 4. Using "do script" and don't do "save as", with redraw off: 1:37min I tried opening the document without a window, but since my script is doing a lot of selections etc., the script as it is now, wouldn't work without a window. But clearly from these timings I will assume, turning off redraw and using do script to not save undo's is the fasted method! Thanks!
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Thu, 19 Mar 2009 10:09
Date: Thu, 19 Mar 2009 10:09
1 lines
754 bytes
754 bytes
But since my script doesn't handle all errors that well, ill just run it without redraw and flush the undos by saving once in a while.
Re: [AS] Script runs slower and slower
Author: Olav_Kvern
Date: Thu, 19 Mar 2009 18:01
Date: Thu, 19 Mar 2009 18:01
7 lines
820 bytes
820 bytes
Hi Thomas, Ah, if your script is doing lots of selections, that's probably another performance bottleneck. Most of the time, you can work without selecting objects. What are you trying to do that requires selection? Thanks, Ole
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Thu, 19 Mar 2009 19:21
Date: Thu, 19 Mar 2009 19:21
5 lines
953 bytes
953 bytes
I do the selections, to search using "find grep" within the selections. I suppose i could pass a text style range instead? My script depends a lot wether things are located in a text style range on the current page or not. But the time the script takes now is OK for this purpose. Turning redraw off almost cut the time in two.
Re: [AS] Script runs slower and slower
Author: Olav_Kvern
Date: Thu, 19 Mar 2009 19:26
Date: Thu, 19 Mar 2009 19:26
7 lines
713 bytes
713 bytes
Hi Thomas, You'd probably want to pass a text object, not a text style range. Thanks, Ole
Re: [AS] Script runs slower and slower
Author: Thomas_Silkjaer
Date: Thu, 19 Mar 2009 20:09
Date: Thu, 19 Mar 2009 20:09
3 lines
841 bytes
841 bytes
Ill experiment a little with it. I create a lot of object references to text, select the referenced text and search it using grep find. I should probably just skip the selection part, don't know why i did it :) Thanks.
Re: [AS] Script runs slower and slower
Author: Olav_Kvern
Date: Thu, 19 Mar 2009 20:28
Date: Thu, 19 Mar 2009 20:28
7 lines
749 bytes
749 bytes
Hi Thomas, Should be fairly easy to make the change--you can just tell the text object reference to find grep.:-) Thanks, Ole
Re: [AS] Script runs slower and slower
Author: Harbs
Date: Fri, 20 Mar 2009 01:02
Date: Fri, 20 Mar 2009 01:02
9 lines
982 bytes
982 bytes
Thomas_Silkjaer@adobeforums.com wrote: > but since my script is doing a lot of selections etc... If you are using selections in your script, chances are, there's better ways to accomplish what you're doing... -- Harbs http://www.in-tools.com
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