Monday, April 22, 2019

#1 2019-04-08 05:42:30 pm

johnmathew
Member
Registered: 2009-10-12
Posts: 91

Bound of Multiple Boxes in Quark

Hi Guys,

I am using MacIntosh X (Yosemite), Quark Xpress 9.5 and Script Editor 2.5.

I created the below script to make a picture box, then to paste it in the cursor position, then to insert some text from the clipboard and to move the cursor to the end of the story.

But What I Need is......
Prompt the user to select box 1. From that bounds create a new text box 1.

Prompt the user to select box 2. From that bounds create a new text box 2.

Repeat until the user Cancelled.
(i.e. Get Bounds of Multiple Boxes and to create Boxes from that bounds)


Thanks in Advance.
Mathew

Applescript:

tell application "QuarkXPress"
activate
tell document 1

set thedata to every text of (the clipboard)
set thedata to thedata as text
set ccount to count paragraphs of thedata

try
set theSelection to selection
set thebox to (make picture box at beginning with properties {bounds:{5, 10, 10, 20}})
delay 0.5
set tool mode to drag mode
tell current page
set selected of thebox to true
set selected of text box 1 to false
cut thebox
end tell

select text box 1
set tool mode to 1
delay 1
paste

set box type of picture box 1 to text box type
select text box 2

set inserttext to paragraph 1 of thedata
set the clipboard to inserttext as text
delay 0.2

paste

set paracount to count of paragraphs of text box 1
set ccount to count characters of paragraph paracount of text box 1
--set ccount to ccount - 1
set selection to insertion point after character ccount of paragraph paracount of text box 1
tell application "System Events" to keystroke tab
delay 0.1


end try
end tell
end tell

Offline

 

#2 2019-04-09 04:30:56 am

CMYS
Member
From:: Belgium
Registered: 2007-07-02
Posts: 83

Re: Bound of Multiple Boxes in Quark

Oh I started to reply on the other forum (Publi-Script). Let's go on over there and we'll post a final version here, OK?

Offline

 

#3 2019-04-15 02:07:54 am

CMYS
Member
From:: Belgium
Registered: 2007-07-02
Posts: 83

Re: Bound of Multiple Boxes in Quark

So here is the code we ended up with. Seems to work perfectly according to John smile

Applescript:


(* This commented part is just meant to populate the clipboard. Select some paragraphs and copy prior to run the script below.

SELECT THE PARAGRAPHS HERE BELOW PRIOR TO RUN THIS SCRIPT !!!

Paragraph 1 from Data File
Paragraph 2 from Data File
Paragraph 3 from Data File
Paragraph 4 from Data File
Paragraph 5 from Data File
Paragraph 6 from Data File
Paragraph 7 from Data File
Paragraph 8 from Data File
Paragraph 9 from Data File
Paragraph 10 from Data File
Paragraph 11 from Data File
Paragraph 12 from Data File
Paragraph 13 from Data File
Paragraph 14 from Data File
Paragraph 15 from Data File
Paragraph 16 from Data File
Paragraph 17 from Data File
Paragraph 18 from Data File
Paragraph 19 from Data File
Paragraph 20 from Data File
Paragraph 21 from Data File
Paragraph 22 from Data File
Paragraph 23 from Data File
Paragraph 24 from Data File
Paragraph 25 from Data File
Paragraph 26 from Data File
Paragraph 27 from Data File
Paragraph 28 from Data File
Paragraph 29 from Data File
Paragraph 30 from Data File



*)


set the_data to every text of (the clipboard)
set the_text to every paragraph of the_data
--set the_count to length of the_text
repeat while ((item -1 of the_text) is "") -- this loop is meant to clean the empty paragraphs
set the_text to (reverse of (rest of (reverse of the_text)))
end repeat
set NOP to length of the_text -- number of paragraphs in Data File, it'll be used later to duplicate the existing line in QXP file a number of times

tell application "QuarkXPress9"
tell document 1
set my_list to {}
set props to properties of every text box -- collecting props of every text box first
repeat with a_box in props
if anchored of a_box is true then -- keeping the text boxes that are anchored
set end of my_list to a_box
end if
end repeat
set NOC to length of my_list -- number of "cells" (anchored text boxes) in line 2
try
if NOP > NOC then
set repeat_line_2 to NOP div NOC
repeat (repeat_line_2 - 1) times
tell story 1 of current box
copy line 2 to after line -1 -- duplicating line 2 as many times as needed according the number of paragraphs we have in Data
end tell
end repeat
end if
end try
set my_list to {}
set props to properties of every text box
repeat with a_box in props
if anchored of a_box is true then
set end of my_list to a_box -- resetting my_list so all the new boxes are taken into account
end if
end repeat
set my_list to reverse of my_list
repeat with j from 1 to length of my_list
try
set story 1 of object reference of item j of my_list to item 1 of the_text -- populating the "cells"
set the_text to rest of the_text -- emptying the list
end try
end repeat
end tell
end tell

beep 2

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)