Am I doing this repeat loop wrong?

I'm writing an AppleScript to transfer layers from OmniGraffle 5 to Adobe Illustrator. It copies the first OmniGraffle canvas perfectly, but when it gets to the second canvas, it copies the last layer of the previous canvas instead. This might be an issue with how I'm changing the layers' "visible" setting at different times. But if is, I don't understand why this would work for the first canvas but not the second when they use the same code.
Any suggestions on how to fix this loop would be greatly appreciated.
set myDocument to "[file path]"
tell application "OmniGraffle 5"
set oDoc to open myDocument
repeat with theLayer in every layer in every canvas in oDoc
set visible of theLayer to false
end repeat
repeat with currentCanvas in every canvas in oDoc
set canvasName to name of currentCanvas
repeat with currentLayer in every layer in currentCanvas
set visible of currentLayer to true
set layerName to name of currentLayer
(* this allows the second layer to be copied *)
tell application "OmniGraffle 5"
activate
end tell
tell application "System Events"
keystroke "a" using {command down}
keystroke "c" using {command down}
end tell
tell application "Adobe Illustrator"
set AIDoc to (make new document)
save AIDoc in canvasName & "-" & layerName & ".ai"
activate
tell application "System Events"
keystroke "v" using {command down}
end tell
end tell
set visible of currentLayer to false
end repeat
end repeat
repeat with theLayer in every layer in every canvas of oDoc
set visible of theLayer to true
end repeat
end tell

well I don't use OmniGraffle, and I don't have Illustrator installed, but the problem is almost certainly with the way you're using GUI scripting (which is unnecessary in this case). try either of the following approaches. you'll have to play with them because (as I said), I don't have the software to test it on. note, for instance, that I'm just guessing that "contents of AIDoc" is a valid reference - I know that Illustrator has some means of addressing the contents of a document, but 'contents' may be the wrong keyword.
<pre class="jive-pre">
set myDocument to "[file path]"
tell application "OmniGraffle 5"
set oDoc to open myDocument
repeat with currentCanvas in every canvas in oDoc
set canvasName to name of currentCanvas
repeat with currentLayer in every layer in currentCanvas
set layerName to name of currentLayer
set the clipboard to currentLayer
tell application "Adobe Illustrator"
set AIDoc to (make new document)
save AIDoc in canvasName & "-" & layerName & ".ai"
set contents of AIDoc to the clipboard
end tell
end repeat
end repeat
end tell</pre>
or if you want to avoid calling the clipboard at all, try setting the layer directly into Illustrator.
<pre class="jive-pre">
set myDocument to "[file path]"
tell application "OmniGraffle 5"
set oDoc to open myDocument
repeat with currentCanvas in every canvas in oDoc
set canvasName to name of currentCanvas
repeat with currentLayer in every layer in currentCanvas
set layerName to name of currentLayer
tell application "Adobe Illustrator"
set AIDoc to (make new document)
save AIDoc in canvasName & "-" & layerName & ".ai"
set contents of AIDoc to currentLayer
end tell
end repeat
end repeat
end tell</pre>
also, it's bad practice to call one app from within another app like this - it creates confusion, and sometimes even generates keyword conflicts. if would be a lot better to move the whole 'tell application "Adobe Illustrator"' block into a subroutine (call it writetoIllustrator(...)), and then call the subroutine with 'my writetoIllustrator(...)' to break it out of the OmniGraffle tell block.

Similar Messages

  • Why does this repeat 32 times?

    I created this script, and it runs fine... the problem is when it's done, it repeats.
    It does this 32 times.
    what it is -->( it deletes data at remote MYSQL database and then insert data from local to the remote database)
    DELETE from table@MYSQL_DR;
    DECLARE
    CURSOR remote_insert is SELECT * FROM tablelocal;
    BEGIN
    for rec in remote_insert loop
    insert into table@MYSQL_DR (rowID, rowOMSCHRIJVING, rowTBT_ID, rowTYPE_RECHTEN)values(
    rec.row_ID,
    rec.rowOMSCHRIJVING,
    rec.rowTBT_ID,
    rec.rowTYPE_RECHTEN
    END loop;
    END;
    I'm using Oracle 10g express linked to a MYSQL database via ODBC 5.1 driver

    852635 wrote:
    it's bugged @ 3 computers doing the same thingOf course. All 3 computers runs the same buggy Apex application page - so the problem will appear on all 3 of these.
    And a developer bug it most definitely is. I have used Apex since project Marvel days and have never ran into an Apex system bug like this. As you have failed to provide any proof that your Apex page and application code are correct, it is simply logical that the error is in your code and not in the Apex system itself.

  • I have a mac book and it is kind of old. When I face time off the macbook it rings and actually calls the device but then while connecting it hangs up. And does it does this repeatedly. Any help would be great.

    how to get my face time calls to go through.

    Hi GAjenifuja,
    It appears you are experiencing an issue with FaceTime calls. That does sound troublesome. The following article provides troubleshooting steps which may help you find a solution:
    FaceTime for Mac: Troubleshooting FaceTime - Apple Support
    Thank you for contributing to Apple Support Communities.
    Take care,
    Bobby_D

  • Iostat -E error messages, what does this mean?

    Good Day,
    st3 Soft Errors: 199 Hard Errors: 11 Transport Errors: 3 Vendor: SUN Product: DLT4700 Revision: CC2E Serial No: Q.
    Because there is hard errors, does this mean something wrong with the tape drive?
    By the way, which instance/driver in "prtconf" show me the scsi controller information ?
    sbus, instance #0 (driver name: sbus)
    SUNW,CS4231 (driver name: audiocs)
    auxio
    flashprom
    SUNW,fdtwo (driver name: fd)
    eeprom (driver name: eeprom)
    zs, instance #0 (driver name: zs)
    zs, instance #1 (driver name: zs)
    sc
    SUNW,pll
    espdma, instance #0 (driver name: dma)
    esp, instance #0 (driver name: esp)
    sd (driver name: sd)
    st (driver name: st)
    sd, instance #0 (driver name: sd)
    sd, instance #1 (driver name: sd)
    sd, instance #2 (driver name: sd)
    sd, instance #3 (driver name: sd)
    sd, instance #4 (driver name: sd)
    sd, instance #5 (driver name: sd)
    sd, instance #6 (driver name: sd)
    st, instance #0 (driver name: st)
    st, instance #1 (driver name: st)
    st, instance #2 (driver name: st)
    st, instance #3 (driver name: st)
    st, instance #4 (driver name: st)
    st, instance #5 (driver name: st)
    st, instance #6 (driver name: st)
    lus, instance #0 (driver name: lus)
    ledma (driver name: ledma)
    le (driver name: le)
    SUNW,bpp (driver name: bpp)
    SUNW,hme, instance #0 (driver name: hme)
    SUNW,hme, instance #1 (driver name: hme)
    SUNW,fas, instance #0 (driver name: fas)
    sd (driver name: sd)
    st (driver name: st)
    sd, instance #7 (driver name: sd)
    sd, instance #8 (driver name: sd)
    sd, instance #9 (driver name: sd)
    sd, instance #10 (driver name: sd)
    sd, instance #11 (driver name: sd)
    sd, instance #12 (driver name: sd)
    sd, instance #13 (driver name: sd)
    sd, instance #14 (driver name: sd)
    sd, instance #15 (driver name: sd)
    sd, instance #16 (driver name: sd)
    sd, instance #17 (driver name: sd)
    sd, instance #18 (driver name: sd)
    sd, instance #19 (driver name: sd)
    sd, instance #20 (driver name: sd)
    sd, instance #21 (driver name: sd)
    st, instance #7 (driver name: st)
    st, instance #8 (driver name: st)
    st, instance #9 (driver name: st)
    st, instance #10 (driver name: st)
    st, instance #11 (driver name: st)
    st, instance #12 (driver name: st)
    st, instance #13 (driver name: st)
    lus, instance #1 (driver name: lus)
    SUNW,UltraSPARC
    pseudo, instance #0 (driver name: pseudo)
    thanks.

    I just got a new Mac and wanted to transfer my old iTunes library to it.  After a night of attempting to import the old library to the new Mac it said that the library was damaged and subsequent restarts yielded the 13010 error.  I deleted everything listed, did a number of iTunes reintalls and the only thing that has allowed iTunes to continue is to dig up a backup library (which is in progress now).  Barring this working, how can I get it so that iTunes boots again as if it is factory fresh?

  • I am trying to activate new itunes card. I am getting error message: The code you have entered has not been properly activated. Does this mean the store did something wrong or me?

    I am trying to activate new itunes card. I am getting error message: The code you have entered has not been properly activated. Does this mean the store did something wrong or me?

    Yes, the store didn't properly activate the card. If the store is nearly then you could try going back and asking them to do so, if it isn't (or if they can't/won't help) then try contacting iTunes Support (you will probably need to give them images of the front and back of the card, and possibly its receipt) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then iTunes Cards And Codes

  • Showing. I RESET. Works, but doing this every day...does not seem right. What am I doing wrong?.

    Classic iPod in Dock, suddenly stops playing. Fully charged, blue play button showing. I RESET. Works, but doing this every day...does not seem right. What am I doing wrong?

    No problem, sometime the iPod need a Reset to clear the overflowing cache.
    So it's good to Reset once a week or after you recharge it.
    Here is the Apple support Article on the 5Rs
    http://www.apple.com/support/ipod/five_rs/classic/
    Have a nice day!

  • HT201272 Some songs are greyed out while others are black. What does this mean and how can I change it? I'm tired of only 2 or 3 songs from an album repeating while the others disappear off the "Up next".

    Please help....I hate iTunes to begin with. Especially the latest they have come up with. Layout drives me crazy. And now....I find maybe a couple of songs in an album as "black" and the other titles are greyed out. What does this mean? I find it very frustrating as the black titles will repeat but the others seem to just disappear off the "play next" list. How can I fix this? And no...downloading from iCloud hasn't helped any.

    This sounds like you have some unchecked tracks. These are skipped during track to track playback. The track names are slightly greyed out in the album view. You can normally see the check boxes from the Songs view or you can change the status via the rght-click context menu.
    tt2

  • When I charge my ipod, the apple symbol comes up as if it was turning on, then it goes black and repeats the process. Sometimes it gets to where I have to put in my 4 digit code to unlock it then goes black, any suggestions on why it does this?

    When I charge my ipod, the apple symbol comes up as if it was turning on, then it goes black and repeats the process. Sometimes it gets to where I have to put in my 4 digit code to unlock it then goes black, any suggestions on why it does this?

    Does it work OK otherwise?
    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Try another cable and USB port and/or charging source
    - Restore from backup. See:                                 
    iOS: How to back up                                                                
    - Restore to factory settings/new iOS device.             
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar                                      

  • I unplugged the power adaptor and suddenly, my mac started beeping repeatedly like an alarm. What does this mean?

    I unplugged the power adaptor and suddenly, my mac started beeping repeatedly like an alarm. My mac was fully charged and would not start up. I pressed down on the restart button to reboot it and the noise stopped.
    What does this mean?

    Hi, it indicates a RAM problem, (or Logic Board around the RAM).
    The power on self-test resides in the ROM of the computer. This test runs whenever the computer is turned on after being fully shut down (the power-on self-test does not run if the computer is only restarted).
    If a fault is detected during the test, you will not hear a normal startup chime. Instead, the system will beep as explained below. If you experience one of these beeps, you may call your Apple Authorized Service Provider for additional troubleshooting assistance.
    1 beep  = no RAM installed
    2 beeps = incompatible RAM types
    3 beeps = no good banks
    4 beeps = no good boot images in the boot ROM (and/or bad sys config block)
    5 beeps = processor is not usable
    In addition to the beeps, on some computers the power LED will flash a corresponding number of times plus one. The LED will repeat the sequence after approximately a 5-second pause. The tones are only played once.
    Note: In this case, a flash is considered to be 1/4 second or 250 ms or greater in length.
    http://support.apple.com/kb/ht1547

  • When I start m/ff browser, the pop-up prompt asking for the master security password appears twice. It was not doing this before. What is wrong?

    When I start the m/ff 3.6.3 browser, the pop-up prompt asking for the master security password appears twice. It was not doing this for the 1st month i had it, and it just started doing it all of a sudden. What could be wrong? O/S = Vista Home Prem.
    == This happened ==
    Every time Firefox opened
    == Afew days ago

    It could be this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=499233 - - multiple master password prompts triggered by filling form logins in multiple tabs
    If you have multiple tabs with form logins restoring when you restart Firefox, that could cause multiple master password prompts.
    There may be other bug(s) causing multiple master password prompts. One way to make the master password a little more usable is the [https://addons.mozilla.org/en-US/firefox/addon/9808/ StartupMaster] add-on, which prompts once for the password at startup, then never bothers you.

  • Does ANYONE know whats wrong with this program?!?!

    Hey(again),
    Does anyone know whats wrong with this program?:
    public class FloatingNumbersTest
    public static void main(String args[])
    float float1 =50.0f;
    float closeFloat=0.001f
    float farfloat=100.0f
    if (float1<=closeFloat)
    System.out.print("Float1 pretty close to zero");
    if (float1>=closeFloat)
    System.out.print("Float1 is near 0");
    if (float1>=farfloat)
    System.out.print("Float1 is not even close to zero!"0
    }There has seemed to be 5 errors!

    public class FloatingNumbersTest
    public static void main(String args[])
    float float1 =50.0f;
    float closeFloat=0.001f
    float farfloat=100.0f
    if (float1<=closeFloat)
    HERE        System.out.print("Float1 pretty close to zero");
    if (float1>=closeFloat)
    System.out.print("Float1 is near 0");
    if (float1>=farfloat)
    System.out.print("Float1 is not even close to zero!"0
    }you're missing the opening { for the first if.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • My Macbook Pro keeps connecting to the wrong wifi.  How do I stop it from doing this?

    My Macbook Pro keeps connecting to the wrong wifi.  How do I stop it from doing this?

    Select the wi-fi tab in the menu bar then select "Open Network Preferences..." Select the "Advanced" button, then select the network that it is interfering with your MBP, then hit the - button and it will "forget" that network. Hope that fixes your problem, good luck.

  • What does the PopUp "Prevent this page from creating additional dialogs" really mean and if I check the Box, how do I undo this if this was the Wrong Thing To Do?

    What does the PopUp "Prevent this page from creating additional dialogs" really mean and if I check the Box, how do I undo this if this was the Wrong Thing To Do?
    Details
    Constantly, while using Firefox (Beta v 11.0), and/or ESPECIALLY, when I have my eMail @ Mail.com open, I get this PopUp stating: "For security reasons, restarting mail.com Mail is possible only via the mail.com Mail Service. Please close this window and restart mail.com Mail" BUT Then there is a CHECKBOX: "Prevent this page from creating additional dialogs."
    I have no idea if Checking this Box is a Good Idea or if it will Screw-Up my mail.com Mail Service...
    Anyone have an answer or explanation of the Use of this Little Check-Box?
    BJ Orden [email protected]

    You do not get any pop-up windows on that website if you tick that box.
    That setting is stored in the cache and you should see pop-ups again if you reload the page and bypass the cache.
    Reload web page(s) and bypass the cache.
    *Press and hold Shift and left-click the Reload button.
    *Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    *Press "Cmd + Shift + R" (MAC)

  • My ipod keeps "turning on" the apple will show up, fade away, and then repeat. It has been doing this for hours.

    my ipod wont turn on. the white apple with the bite appears, stays for about 10 to 15 seconds like it normally does for booting up, then fades away and the screen goes black. 5 seconds later it repeats. it has been doing this for hours now. I tried the home and power button thing and the screen went black. then i hit the power button and it continued to do the same thing. i tried plugging it in to my wall, my charger recognised that it was charging. i tried plugging it into my computer and it made a sound like something was plugged in. but nothing came up.

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable                                                       
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar                                     

  • Why does this message keep appearing when i try to instal windows 7 through bootcamp? - "something went wrong and the USB cannot be configured for the installation"

    Why does this message keep appearing when Itry to instal windows 7 through bootcamp? - "Your bootable USB drive could not be created. An error occurred while copying the Windows installation files."

    Found a solution!
    Follow the extended version of these directions here:
    https://discussions.apple.com/docs/DOC-3581
    Worked like a charm!

Maybe you are looking for