I’m not a newbie to Applescript, but trying to script Quark to get file paths for images is driving me absolutely bonkers.
I’m trying to write a script that, in part, needs to get the file path to all images on the page. Can someone with more experience with Quark explain to me why this doesn’t work. Every time I run it, I get the error "Can’t get path of <> 1 of <> 1 of <> 1 of document 1.
tell application “QuarkXPress”
activate
tell document 1
repeat with z from 1 to (count of every «class GRBX»)
tell «class GRBX» z
repeat with x from 1 to (count of every «class PICB»)
tell «class IMAG» 1 of «class PICB» x
display dialog (file path as text)
end tell
end repeat
end tell
end repeat
end tell
end tell
In case you’re wondering, this is part of a bigger script. I removed all other stuff to try debugging this, but I still get the error.
Also, for some bizarre reason, Applescript replaced all of my object references with those weird bracketted strings like «class IMAG» which I find extremely annoying. Why did that happen? I used to have things written about like “picture box” and “group box” and now it’s showing as this. I’ve never seen this happen before.
Regarding the chevrons round “objects etc” in your code refer to page 123 of the Applescript Language guide for a full explanation but it is probably due to the Quark dictionary not being available when you edited the code.
If you can post the code again after fixing this then I will try to help with the actual problem but try this in the mean time:
tell application “QuarkXPress”
activate
tell document 1
set imagebase to every picture box of page 1
repeat with x in imagebase
set yy to (file path of image 1 of x) as string
display dialog yy
end repeat
end tell
end tell
Try quiting script editor and launch it again when Quark is already running. I’ve seen this happen if I tried to open a script and the application I was scripting was not already open. Usually, quiting script editor and open my script up again will correct that issue.
Good Luck,
Dave
Model: 2.3 GHz Dual G5
AppleScript: 1.10
Browser: Firefox 1.0.4
Operating System: Mac OS X (10.4)
Try this (includes page number of your Quark file and the vertical (Y) scale percentage it is used at) :
set piclist to ""
set thisline to ""
set filename to ""
tell application "QuarkXPress"
activate
tell document 1
repeat with p from 1 to (count of pages)
tell page p
set m to the name
repeat with i from 1 to (count of picture boxes)
tell picture box i
if not (bounds of image 1) = {0, 0, 0, 0} then
set filevar to file path of image i of it as text
set filename to my getfileName(filevar)
copy (scale of image 1 of it as list) to {sc1, sc2}
set thisline to m & " " & filename & " " & (sc1 as text) & return
set piclist to piclist & thisline
end if
end tell --picture box i
end repeat --picture boxes i
end tell --page
end repeat --pages p
end tell --document
end tell --application
tell application "TextEdit"
make new document at beginning with properties {text:piclist as Unicode text}
activate
end tell --application
on getfileName(path)
set pathstr to (path as string)
end getfileName