XPress 6.5: text box part of group box

Hi everybody,

I am scripting QuarkXPress 6.5 with AppleScript.
Now my problem:
Is there a way to tell if a (specific) text box is part of a group box?

Looking forward to your answers,

Andreas

This was fun working out as I had no idea off the top of my head. Simple answer is get the uniqueID of your text box and see if it in any groups anywhere.

tell application "QuarkXPress"
	activate
	--Script will break if there no textboxes in any group.
	try
		set x to text boxes of group boxes of layout spaces of project 1
	on error
		display dialog "No point continuing as there's no textboxes in any group." buttons "Finish" default button "Finish"
		return
	end try
	--	Choose the textbox
	set TextBoxID to uniqueID of text box 1 of page 1 of document 1
	--See if in any group
	if uniqueID of text boxes of group boxes of layout spaces of project 1 contains TextBoxID then
		set InGroup to true
	else
		set InGroup to false
	end if
end tell
--Report the result
if InGroup then
	set Report to "Your text box is in a group."
else
	set Report to "Your text box is free and is not in a group."
end if
display dialog Report

Of course if there no group anywhere the script will fault, so I put a test at the beginning.

Hope this help.

Hi bevos,

thank you very much. Your proposal helped me so much I can’t tell (and worked inspite of my lousy English explanation!)

Once again: thanks a lot,

Andreas

Thats OK, AppleScript is English so I guess I’ve got an advantage. Next you likely asked how do you group and ungroup in Quark by Applescript :slight_smile:

Hi bevos,

how would you like this one?

Just to tease you I left one German button in it, ok? Guess what it means!

tell document 1 of application “QuarkXPress 6.52”
activate
repeat with i from (count of group boxes) to 1 by -1
try
tell group box i
set grouped to false
end tell
end try
end repeat
display dialog “Fertig.” buttons “OK” default button 1 with icon 1 giving up after 1
end tell

Greetings,

Andreas

… and thanks again! :slight_smile:

Grüezi!
It means ‘Finished’. Yes your script ungroups everything. You have done a a repeat backward. I have my ideas why but this work fine for me. And would be quicker.

tell application "QuarkXPress"
	activate
	tell document 1
		try
			tell group boxes
				set grouped to false
			end tell
		end try
	end tell
	display dialog "Lucky I've finished." buttons "OK" default button 1 with icon 1 giving up after 1.666
end tell

Grüass Di bevos, (just the Bavarian translation of the Swiss “Grüezi”)

because: My AppleScript tells me also “Lucky I’ve finished” but not until crashing XPress before.
I am working with quite complex catalog (catalogue) pages and I experience in general that a script concerning all grouped boxes leads to a crash. I am still wondering why but it urges me to loop smoothly through these sensitive “Princess and the pea” boxes.
Didn’t you experience a similiar behavior?

Andreas :rolleyes:

Mine crashed if I had something was selected. But if nothing selected it work fine. Can’t say my document was that complex.

I guess your backwards method was because of a crashing.

I use a English to German translator and I got Swiss how mad :slight_smile:

I am trying something similar with Quark XPress 6.5. I need to be able to drop a series of files on a script app and have it process the Quark files and ignore the rest. When I try to add an ‘on open’ function as an app, it fails. If I leave it out, I can process one file at a time, this does not work for hundreds of Quark files…


on open y
	set x to 1
	repeat number of items in y times
		set z to info for item x of y
		if z is not folder then
			if file type of z is "XPRJ" then
				tell document 1 of application "QuarkXPress"
					repeat with i from (count of group boxes) to 1 by -1
						try
							tell grouped box i
								set grouped to false
							end tell
						end try
					end repeat
					close saving yes
				end tell
			end if
		end if
	end repeat
end open


The odd thing is that this works:


tell document 1 of application "QuarkXPress"
	repeat with i from (count of group boxes) to 1 by -1
		try
			tell grouped box i
				set grouped to false
			end tell
		end try
	end repeat
	close saving yes
end tell

thanks,
Levon

Model: Dual 2.3GHz G5
AppleScript: 2.1.1/SD4
Browser: Firefox 2.0.0.4
Operating System: Mac OS X (10.4)