Quark - Delete empty boxes - Help

Hello guys,

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.

Greetings, Sikanda

Try this.

if content = none content and name of color = “Kein” or name of color = “None” or the width of the frame = “0 pt” then

I think that you would want the following:

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

if content = none content and the width of the frame = "0 pt" as thick units and name of color = "Kein" or name of color = "None" then

Thanks mdudek,

If I put your piece of code into the script, I get an error from the Scripteditor:

"AppleScript-Error

“0 pt” kann nicht in Typ «class F_TH» umgewandelt werden."

Which means in english something like this:

“0 pt” can’t be changed to type «class F_TH»"

hm…

Hmmm Quark 6.5.
Not a lot of experience there.

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.

You might also try coercing the value from a Quark class to a string:

(width of the frame) as string

Sorry guys, I’m very late for answer but I had much work to do. Here are my results:

@mdudek:

If I use this Script on the pages:

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 get this in the result window:

What shall I do next? (I’m really a beginner)

@Jerome:

Sorry, I don’t know how I can use this in the script. Could you be more precisely please?

Greetz and thanks for your help so far…

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.

Here is the final script:

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!

Greetings, Sikanda