so this is my first post and it contains already a bidding for help. Hope, it’s ok.
I used the search function and with your help from Post http://macscripter.net/viewtopic.php?id=15058
I have a script now, that works already, but not perfect. Perhaps anyone of you has a clue for me how to get my
problem solved:
Our customer sends Quark 6.5 files, which contains 5-10 empty boxes with no content. I want to delete these boxes.
Here is the script:
tell application "QuarkXPress_6.52"
if exists front document then
tell front document
set BoxToDeleteList to {}
set picBoxcount to count every generic box
set tot to count (every generic box whose content = none content and name of color = "Kein" or name of color = "None")
repeat with i from 1 to picBoxcount
tell generic box i
try
if content = none content and name of color = "Kein" or name of color = "None" then
set BoxToDeleteList to BoxToDeleteList & uniqueID
end if
end try
end tell
end repeat
display dialog "Es wurden " & tot & " leere Kästen gefunden." buttons {"Löschen"} default button 1
repeat with i in BoxToDeleteList
tell (every generic box whose uniqueID = contents of i)
delete
end tell
end repeat
end tell
end if
end tell
It works like a charm, thanks to you guys, but still one thing doesn’t work:
there are boxes on the pages that contain nothing but have frames/borders that will be deleted too. But these must stay on the pages because they are design elements. Is there a way to pass by these boxes, so that only the real empty boxes are deleted? I read something aber “frame record” but don’t have any idea to use this.
if content = none content and the width of the frame = "0 pt" and name of color = "Kein" or name of color = "None" then
The way mdudek worded it a box whose content was none, color was red, and frame was 0 would test true since he used a continuation of the or line for the width of the frame. I switched it to be an and so the box would need to have a content of none and frame of 0 width and be colored Kein or none.
First of all thank you guys for your quick replys. Today I tested both of your variants, but what happens is that the empty boxes now aren’t deleted.
It seems as if the criteria "frame width = “0 pt” " don’t work with the boxes.
I checked the properties of the boxes I want to delete again and they are: content: none, frame: 0 pt, color: none.
I really don’t know what the mistake can be.
Try this…
Write a short script that puts the value of a frame width into a variable,
then get the class of that variable.
set frame_width to the width of the frame of generic box…
class of frame_width
which will be returned in the result window.
try setting “0 pt” to that class instead of thick units.
tell application "QuarkXPress_6.52"
tell front document
set frame_width to the width of the frame of every generic box whose content = none content and name of color = "Kein" or name of color = "None"
end tell
end tell
I can’t recreate your problem.
Maybe it’s localized Quark issue.
But this is how I would work through it.
I would create a Quark document with at single picture box.
This box, like the boxes you want to delete, has no frame.
In a script I would:
tell “QuarkXPress”
tell document 1
get the properties of generic box 1
end tell
end tell
The properties of the box will be returned in the event log.
There will be a list of the frame properties
frame:{color:color spec “Black” of document “Project1” of application “QuarkXPress”, gap color:null, gap shade:“100%”, inside trap:default, outside trap:default, shade:“100%”, style:solid, width:"0 pt, gap opacity:“100%”}, skew:“0°”}
What ever is returned as the width I would use as criteria for evaluating if the frame exists on the box.
Mine returns “0 pt” yours returns something like «data F_TH00000000».
if content = none content and the width of the frame = «data F_TH00000000» and name of color = “Kein” or name of color = “None” then
if that doesn’t work I would try to determine if the class of the two values agree.
set frame_width to the width of the frame of generic box 1
class of frame_width
run this get the results and then comment it out and run
class of «data F_TH00000000»
Are they the same class? If not, you will need to coerce the two items to be the same class before you can evaluate them.
You might need to coerce the width of the frame to string or «data F_TH00000000» to whatever class is returned by the width of the frame.
tell application "QuarkXPress_6.52"
if exists front document then
tell front document
set tool mode to drag mode
set BoxToDeleteList to {}
set picBoxcount to count every graphic box
set tot to count (every graphic box whose content = none content and name of color = "Kein" or name of color = "None")
repeat with i from 1 to picBoxcount
tell graphic box i
try
if content = none content and name of color = "Kein" or name of color = "None" then
set tmpFrameWidth to width of frame
set tmpFrameWidth to coerce tmpFrameWidth to real
if tmpFrameWidth = 0 then
set BoxToDeleteList to BoxToDeleteList & uniqueID
end if
end if
end try
end tell
end repeat
if tot = 0 then
display dialog "Es wurden keine leere Kästen gefunden." buttons {"OK"} default button 1 with icon 1
else
display dialog "Es wurden " & tot & " leere Kästen gefunden." buttons {"Löschen"} default button 1 with icon 1
repeat with i in BoxToDeleteList
tell (every graphic box whose uniqueID = contents of i)
delete
end tell
end repeat
end if
end tell
end if
end tell
To coerce the width of frame to real does it finally.
With the tips from you guys and I finally got the Script to work.
Thanks to all of you and I wish you all a happy new year!