Author Topic: q8 as: copy selection to pasteboard question  (Read 2751 times)

0 Members and 1 Guest are viewing this topic.

Offline 4610036

  • Jr. Member
  • **
  • Posts: 50
  • Karma: 0
  • Gender: Female
q8 as: copy selection to pasteboard question
« on: June 16, 2009, 12:10:22 PM »
hi guys. 

I'm not sure what i'm doing wrong. the idea behind the script is to:
  • copy all elements from one document,
  • create a new document with the same specs,
  • and paste all elements
  • (repeat for each page)

at this point in the script (below), ive already gotten the layout specs from the original file (referred to here as "last" project) and have created a new file, replicating specs ("first" project).

clearly i was too optimistic, but i really thought this would work. [sigh]. i was sort of hoping i was getting to the stage of being able to "bang out" a quick basic script.  :-\

any help would be most appreciated. ;D

tell application "QuarkXPress"
   activate
   repeat with i from 1 to (count of pages)
      tell layout space 1 of last project
         set tool mode to drag mode
         tell page i
            set selected of (every generic box) to true
            tell selection
               copy it to clipboard
            end tell
         end tell
      end tell
      tell layout space 1 of first project
         set tool mode to drag mode
         tell page i
            paste clipboard
         end tell
      end tell
   end repeat
end tell

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Re: q8 as: copy selection to pasteboard question
« Reply #1 on: June 17, 2009, 03:12:27 AM »
Haven't tested it but would this work?

Code: [Select]
tell application "QuarkXPress"
    activate
    tell layout space 1 of last project --this line first to get count of paras later on
        try
            set tool mode to drag mode --this part in a try block, just in case (I'm not sure if it's 100% necessary)
        end try
        repeat with i from 1 to (count of pages)
            tell page i
                set selected of (every generic box) to true
                --tell selection
                    copy --it to clipboard [I think copy on its own would be enough]
                --end tell
            end tell
        end tell
        tell layout space 1 of first project
            try
                set tool mode to drag mode
            end try
            tell page i
                paste --clipboard [just paste]
            end tell
        end tell
    end repeat
end tell

Let me know how it works for you.
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz 10 Go 1066 MHz DDR3 Mac OS 10.8.5 QuarkXPress 9.5.4.1 Adobe CS5 =

Offline 4610036

  • Jr. Member
  • **
  • Posts: 50
  • Karma: 0
  • Gender: Female
Re: q8 as: copy selection to pasteboard question
« Reply #2 on: June 19, 2009, 11:16:17 AM »
jean-marie
i tried your code.... it didnt work for me.  i would have thought "copy" and "paste" would work (again, in the optimistic world i try to live in), but nothing gets copied. even if i just run it as far as "copy", then try to paste manually, there is nothing in the clipboard.

I also tried putting the repeat outside the "tell app" statement so that it could repeat for each page

repeat with i from 1 to page_count
tell application "QuarkXPress"
activate
tell layout space 1 of last project
set tool mode to drag mode
tell page i
set selected of (every generic box) to true
get contents of selection
set pg_stuff to result


i'm about ready to give up on this tactic. this script was supposed to be a solution to not being able to get rid of the blacklining plugin (oh, btw, its a company in the UK and they did not respond to my email requesting a black-lining killer).  if i create a new document and copy all elements over to the new doc, it loses the plug-in issue. 

thanks very much for your help. 
« Last Edit: June 19, 2009, 11:21:08 AM by 4610036 »

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Re: q8 as: copy selection to pasteboard question
« Reply #3 on: June 22, 2009, 03:03:20 AM »
jean-marie
i tried your code.... it didnt work for me.  i would have thought "copy" and "paste" would work (again, in the optimistic world i try to live in), but nothing gets copied. even if i just run it as far as "copy", then try to paste manually, there is nothing in the clipboard.

I also tried putting the repeat outside the "tell app" statement so that it could repeat for each page

repeat with i from 1 to page_count
tell application "QuarkXPress"
activate
tell layout space 1 of last project
set tool mode to drag mode
tell page i
set selected of (every generic box) to true
get contents of selection
set pg_stuff to result


i'm about ready to give up on this tactic. this script was supposed to be a solution to not being able to get rid of the blacklining plugin (oh, btw, its a company in the UK and they did not respond to my email requesting a black-lining killer).  if i create a new document and copy all elements over to the new doc, it loses the plug-in issue. 

thanks very much for your help. 
I'm sorry it doesn't work for you. As I said I haven't tried it myself but I've already used the paste verb in AS with Quark quite successfully as far as I remember
Reading your code, I must admit I'm surprised to see the repeat loop there. I would put it after the set tool mode line (for it's necessary to set it only once then loop).
Is your script seem to do what it says? I mean are you seeing on your display all boxes getting selected? Contents of selection doesn't sound canonical to me (but I already said I'm not an Ace  :D).
Also I realize dealing with first and last project is dangerous because when you call the last project it becomes ipso facto the first one. You should set into 2 variables the name of each project you're working on and call them after their variable name.
Give this a shot and call again if needed.
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz 10 Go 1066 MHz DDR3 Mac OS 10.8.5 QuarkXPress 9.5.4.1 Adobe CS5 =

Offline 4610036

  • Jr. Member
  • **
  • Posts: 50
  • Karma: 0
  • Gender: Female
Re: q8 as: copy selection to pasteboard question
« Reply #4 on: June 22, 2009, 04:45:41 PM »
thanks jean-marie.

the reason i put the repeat at the top was so i could repeat for each page... basically start in the source-document, copy page 1, go to new-document and paste page 1. repeat for page 2 and so on.  otherwise it seemed content would get misplaced. 

the select is working.  but you could be right that the "get contents of selection" is bad code... in fact it must be because it doesnt work (LOL). so at this point the only thing that has succeeded is setting the selected to true. :-) 

my logic is flawed on this project and perhaps needs re-evaluation. i should just be happy to create a new document with the same layout properties and let the user do some work! (drat, I am the user). 

thanks for your help.  i'll keep tinkering to see if i can get the copy and paste codes to work (just for my own satisfaction) but perhaps i'll let go of the bigger project (at least for now).
 :) -margaret

Offline AutoFetishist

  • Sr. Member
  • ****
  • Posts: 397
  • Karma: 2
  • Gender: Male
Re: q8 as: copy selection to pasteboard question
« Reply #5 on: August 12, 2009, 01:55:34 PM »
Margaret,

I have the blacklining plug-in as well. There is a command under the Blacklining menu called "Clean and Reset Project" which does what you say you were trying to (strip the document of its marks).

If that doesn't work, what about temporarily removing the XT, and then opening the documents, saving down, then reopening?

A/F

p.s. what country are you in?

Offline 4610036

  • Jr. Member
  • **
  • Posts: 50
  • Karma: 0
  • Gender: Female
Re: q8 as: copy selection to pasteboard question
« Reply #6 on: August 12, 2009, 03:20:24 PM »
hi a/f
i am in new york   :) tho i'm not from new york. what country are you in?
thanks for the info. the problem is that the blacklining was added in a previous version of quark (i am in 8.) using the blacklining plugin which doesnt exist (and we dont need it in our versn). "open with suppress warnings" doesnt seem to catch it. 
i actually got around the problem by putting in a sys event 'try to hit OK', which takes care of the warning and doesnt trip the open file process.
of course sys events are just plain precarious in my view -- not to mention slowing things down -- but maybe thats just me.
thanks for the info on the plugin tho. it would be a good fix if we had access to the file originators.
m./

Offline AutoFetishist

  • Sr. Member
  • ****
  • Posts: 397
  • Karma: 2
  • Gender: Male
Re: q8 as: copy selection to pasteboard question
« Reply #7 on: August 20, 2009, 10:23:34 AM »
Sorry I'm just getting back to you---

How many files were you talking about, BTW?
Maybe I could do it for you? (I'm still in 6.5)

Offline 4610036

  • Jr. Member
  • **
  • Posts: 50
  • Karma: 0
  • Gender: Female
Re: q8 as: copy selection to pasteboard question
« Reply #8 on: August 21, 2009, 09:29:29 AM »
a/f

you are super-nice to offer.  i am ok with the solution with the sys event. it was important from a script stand-point that i accommodate the possibility that this warning would come up. i couldnt tell my team that they could use the script except for this one format.  in actuality the format is not a common one for the client to send us. however, since we edit their files, it is not a finite group of files.

thanks so much for the offer. :)

oh and i did manage to get the copy/paste to work ... almost ...heee. if i get time on monday i'll see if i can post it... for those of you who dont mind untangling my conundrums  ;D

m./
p.s. you didnt tell me what country youre in ;)