• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Quirks of Annotate script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quirks of Annotate script


  • Subject: Re: Quirks of Annotate script
  • From: Hans Haesler <email@hidden>
  • Date: Sun, 31 Dec 2006 12:29:36 +0100

Herbert,

you're welcome.

Are you running the script from the XPress Scripts Menu?
It should run a little faster than from Script Editor.

But what about some more speed? :-)
---
global bgColor
global curPage

tell application "QuarkXPress 6.52"
 activate
 if (document 1 exists) then
  tell document 1
   try
    delete (every text box whose name contains "annotate")
   end try
   set {hm, vm} to {horizontal measure, vertical measure}
   if hm is not points or vm is not points then
    set properties to {horizontal measure:points, vertical measure:points}
   end if
   set bgColor to "Yellow"
   if not (color spec bgColor exists) then
    set bgColor to name of color spec 1 whose locked is true and ¬
     CMYK color value is {0, 0, 65535, 0}
   end if
   set selection to null
   set view scale to fit page in window
   repeat with p from 1 to count of pages
    set curPage to p
    --show page p
    do script {annotate}
   end repeat
   if hm is not points or vm is not points then
    set properties to {horizontal measure:hm, vertical measure:vm}
   end if
  end tell
  set AppleScript's text item delimiters to {""}
  display dialog "Done." buttons "OK" default button 1 with icon 1 giving up after 1
 else
  display dialog "Open a document, please." buttons "OK" default button 1 with icon 2
 end if
end tell

script annotate
 set AppleScript's text item delimiters to ":"
 tell document 1 of application "QuarkXPress 6.52"
  tell page curPage
   repeat with i from 1 to count of picture boxes
    set filePath to (file path of image 1 of picture box i) as Unicode text
    if filePath is not in "nullno disk file«class null»«constant ****Ndft»" then
     set filename to text item -1 of filePath
     tell picture box i
      set {sc1, sc2} to scale of image 1 as list
      set {y1, x1} to origin of bounds as list
     end tell
     set y2 to ((y1 as real) + 14)
     set x2 to ((x1 as real) + 175)
     make text box at beginning with properties {bounds:{y1, x1, y2, x2} ¬
      , color:bgColor, name:"annotate", runaround:none runaround}
     tell story 1 of text box 1
      set properties to {font:"Times", size:12, contents:filename & "  " & (sc1 as text)}
     end tell
    end if
   end repeat
  end tell
 end tell
end script
---
Using 'do script' speeds up execution. But it also deactivates
the undo function. Before continuing to work on the document
you should turn 'undo' on, again: Duplicate and delete a box.

Another problem with 'do script': When run from the Scripts Menu
it sometimes returns the file path of empty boxes or pasted
PICTs as raw codes. The test of the file path must cover this.
I used a string which is almost three times faster than the
traditional '... and if file path is ...'.

Another small gain of speed comes from adressing 'text box 1'
(instead of 'text box ("annotate" & i)) and setting the
properties in one go.

This version of the script doesn't show the current page.
If you'd like to see that the script is working, then just
uncomment the line 'show page p'. But this would be slower.

I replaced the "yellow" of the original script with a variable.
This avoids an error message if the program language of
QuarkXPress doesn't contain "English".

Is the script fast enough? If not, then it will run _much_
faster when the window of the XPress document is made as
small as possible. But then you should delete (or comment
out) the line 'set view scale to fit page in window'.

A Happy New Year!
Hans


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden

  • Prev by Date: CAUTION: Stuffit Deluxe 11 scripting change
  • Next by Date: Re: AppleScript-Users Digest, Vol 3, Issue 652
  • Previous by thread: CAUTION: Stuffit Deluxe 11 scripting change
  • Next by thread: Re: Quirks of Annotate script
  • Index(es):
    • Date
    • Thread