After using an ExtendScript (via ESTK) Illustrator becomes corrupted and "Can't open illustration."

Hey, thanks for reading.
I'm having a strange problem with Illustrator CS5 and ESTK CS5. I'm new to writing ExtendScripts, so I haven't a clue what could be going wrong here but here's the skinny:
I've written the following code, which is very specialized to the exact document I'm working with. Using the ExtendScript Toolkit, the script goes through the following loops:
The primary problem:
For some reason, running this script causes Illustrator to become somehow corrupted. I can continue working with the document as long as it is open, but if I try to close it and re-open it, I get the infuriatingly unhelpful error dialog "Can't open illustration." With no extra details.
The same error comes up if I try to open any other .ai files. Shutting down and rebooting doesn't fix the problem. I have to completely uninstall Illustrator, then re-install it before it will work again. And even then, if I try to open the ExtendScript-corrupted file the whole Illustrator app gets corrupted and needs to be reinstalled.
Oh, also Illustrator itself shows up as "(Not responding)" while the script is running, but the ESTK console clearly shows that the script is chugging along as expected.
Specifics about the script:
There are 4 "Buttons" on the document, and a library full of nearly-identical symbols in the Library (different colored backgrounds for the buttons).
The script cycles through every symbol in the library, replacing and deleting instances of the previous symbol.
Then, for each symbol, it cycles through an array (technically an object-literal) of { language-code: "string" } pairs, and saves a .png of each artboard for each word.
What follows is a pared-down version of the full script:
(I tried to add a few $.sleep(10); calls, hoping that maybe just a brief slowdown in the processes might help. It didn't.)
This script (in its original form) outputs a ton of files very, very quickly.
Script Example
var folder = Folder.selectDialog();                     // Ask for a folder choice.
var aDoc = app.activeDocument;                        // Declare an active Document reference.
var textLayer = aDoc.layers.getByName('text');   // Get the text layer, for moving it back/forward
var textFrms = aDoc.textFrames;                       // Get all text frames, for language swap
var allSymbols = aDoc.symbols;                         // Get array of all symbols in the symbol library
var allSymbolItems = aDoc.symbolItems;            // Get an array of all symbol instances in the active document
var helpTextArray =
    en: "help",
    az: "Kömək",
    cs: "Nápověda",
    da: "Hjælp",
    de: "hilfe",
    el: "Bοήθεια",
    en: "help",
    es: "ayuda",
        * There's normally 3 arrays with many more languages / translations
if( aDoc &&                                      // We have an activeDocument
     folder &&                                    // and we have a selected output folder
     allSymbols.length > 0 &&             // We've got symbols
     allSymbolItems.length > 0 &&      // and we've got symbol instances "symbolItems"
     textFrms.length > 0 ) {                 // and we've got textFrames to manipulate.
    // For each symbol in our symbol library...
    for(var i = 0; i < allSymbols.length; i++) {
        // Run through all instances of symbols (symbolItems), and replace with a different symbol.
        for(var ii = 0; ii < allSymbolItems.length; ii++) {
            // Move text layer out of the line of fire.
            $.writeln('Move text to back');
            textLayer.zOrder(ZOrderMethod.SENDTOBACK);
            var currObj = allSymbolItems[ii];
            var newObj = aDoc.symbolItems.add(aDoc.symbols[i]);
            var symbolColor = aDoc.symbols[i].name;
            // Add the new / replacement symbol.
            newObj.left = currObj.left;
            newObj.top = currObj.top;
            newObj.width = currObj.width;
            newObj.height = currObj.height;
            // Remove the old symbol.
            currObj.remove();
            // Bring text back up to the front.
            $.writeln('Bring text to front');
            textLayer.zOrder(ZOrderMethod.BRINGTOFRONT);
            redraw();
            $.sleep(10)
        // Run through each language and each buttonText and save a copy.
        var currArray = helpTextArray;
        var currArrayName = "help";
        for(currLang in currArray) {
            switchText(currLang, currArray);
            $.sleep(10)
            // Run function to save .pngs of each artboard
            exportAll(currLang, symbolColor, currArrayName);
        } // end for (currLang in currArray)
    } // end symbols.length
} // end if
function switchText(lang, array) {
    //var textFrms = activeDocument.textFrames;
    var newText = array[lang];
    newText = (newText === "") ? array["en"] : newText;
    for(var i = 0; i < textFrms.length; i++) {
        var isHorizontal = ( textFrms[i].width > textFrms[i].height );
        var scale = 100;
        var scaleMatrix;
        textFrms[i].contents = newText;
           * There's normally an automatic text-resizer here
    } // for var i
function exportAll(lang, color, buttonText) {
    var artBds = aDoc.artboards;
    var options = new ExportOptionsPNG24();
        options.antiAliasing = true;
        options.transparency = true;
        options.artBoardClipping = true;
    for(var i = 0; i < artBds.length; i++) {
         var currBoard = artBds.setActiveArtboardIndex(i);
         var buttonPosition =  artBds[i].name;
         var newFile = new File(folder.fsName+"/"+buttonText+"_"+color+"_"+buttonPosition+"_"+lang+".png");
         aDoc.exportFile(newFile,ExportType.PNG24,options);
         $.writeln('A file was saved with the name:: '+buttonText+'_'+color+'_'+buttonPosition+'_'+lang+'.png');
         $.sleep(10)
function revertToOriginal() {
    $.writeln('Revert');
    // Switch the text back to help.
    switchText("en", helpTextArray);
    // For each symbol instance...
    for(var i = 0; i < allSymbolItems.length; i++) {
        // Move text layer out of the line of fire.
        $.writeln('Move text to back');
        textLayer.zOrder(ZOrderMethod.SENDTOBACK);
        var currObj = allSymbolItems[i];
        // Add in the placeholder since we're reverting.
        var newObj = aDoc.symbolItems.add(aDoc.symbols[0]);
        var symbolColor = aDoc.symbols[0].name;
        // Add the new / replacement symbol.
        newObj.left = currObj.left;
        newObj.top = currObj.top;
        newObj.width = currObj.width;
        newObj.height = currObj.height;
        // Remove the old symbol.
        currObj.remove();
        // Bring text back up to the front.
        $.writeln('Bring text to front');
        textLayer.zOrder(ZOrderMethod.BRINGTOFRONT);
        redraw();
        $.sleep(10)
        $.writeln('REVERT');
revertToOriginal();
Are there best practices that I'm unaware of here that could be causing this corruption?
Does anyone know what could be happening?
The only error I ever get is "Can't open illustration." There's never anything more helpful, so I have no idea what could be going wrong.
If there's any more information that would be of use to anyone I'd be happy to share. This is wasting a lot of my time and making me pull my hair out like crazy,

I have not had the time to look over your script but at a glance there are a few things I would handle differently…
Firstly returning a document to a given state… If you play with this snippet you can see that app.undo() returns to the last called app.redraw() if there is one else it undo's the whole script…
#target illustrator
doSymbols();
function doSymbols() {
    var doc = app.activeDocument;
    var sym = doc.symbols[0];
    for ( var i = 0; i < 4; i++ ) {
        var foo = doc.symbolItems.add( sym );
        foo.position = Array( i * 72, -( i * 72 ) );
        app.redraw(); // Comment this out to see…
    app.undo(); // Returns to last redaw state if any…?
Secondly your symbols… You know you can just change the symbol instance's symbol reference…? If they are almost the same particualy size then its an easy swap…?
#target illustrator
doSymbols();
function doSymbols() {
    var doc = app.activeDocument;
    var sym = doc.symbols[1]; // Next symbol in the palette
    for ( var i = 0; i < 4; i++ ) {
        doc.symbolItems[i].symbol = sym;
        app.redraw();

Similar Messages

  • Why after downloading a pdf am I getting that the file is corrupt and can not open?

    why after downloading a pdf am I getting that the file is corrupt and can not open?

    Probably the file got corrupted during the download?  Download it again.
    If that does not correct the problem, can you share that file download?

  • When Password Protected - The File Becomes Corrupted and I Can Not Open It

    I have password protected two files now in Excel 2007.  After opening and then saving a few times, the file becomes corrupted and I cannot open.  The following error message appears  "Excel cannot open the file"XXXX.xlsx" because
    the file format or file extenson is not valid.  Verify that the file has not been corrupted and that the file extension matches the format of the file.
    The files that I created contains sensitive information and I really need to get to them.l

    You can try to open these files with 'Open and Repair' .
    1.Start Excel.
    2.click the Microsoft Office Button, and then click Open.
    3.In the Open dialog box, click to select the file that you want to open.
    4.Click the down arrow on the Open button, and then click Open and Repair.
    Also this issue could be  caused by malware on the affected machine
    Please see:http://blogs.technet.com/b/the_microsoft_excel_support_team_blog/archive/2013/09/07/quot-cannot-open-the-file-because-the-file-format-or-extension-is-invalid-quot-opening-office-files.aspx
    Some one works out this issue with remove the xlsx entention,give it a try.
    1. rename the file and remove the .xlsx or .xls extention etc e.g. if my file is called test.xlsx I remove the '.xlsx' - you will get a warning message saying this could make the document unstable - accept it
    2. the document icon should now have turned white (the document won't look like an excel document anymore)
    3. open a blank excel document by hitting start -> all programs -> Microsoft office -> excel (this may be different if your not on windows 7)
    4. in your blank excel document hit file -> open
    5. navigate to the document you renamed above and select it, now click open

  • After a power failure while iPhoto was running, I get the message "Your photo library is either in use by another application or has become unreadable"  and iPhoto will not open????

    After a power failure while iPhoto was running, I get the message "Your photo library is either in use by another application or has become unreadable"  and iPhoto will not open???? held down the option and the command and tried to run what was ticked off and it just sits there with a spinning wheel and does nothing, can I throw the app away and download a new one? or will it still not open?

    , can I throw the app away and download a new one? or will it still not open?
    You could, but the error message is indicating that your iPhoto library needs repairing.
    Check, if iPhoto will run, if you launch it on a new library. Hold down the alt/option key, while you launch iPhoto. Select to create a new library from the panel that will show. Can you create a new library? If yes, try again to fix the library. Which options have you tried from the Library First Aid panel, when you launched iPhoto with the option and command key held down?
    If you have not tried "Rebuild"; do that next. But be sure to make a backup of your iPhoto library, before you try this.

  • Modified Files on FCPX... Random files in event folder(that I used to make a multicam clip) become modified and unusable. Is there anything i can do to prevent this?

    Since I upgraded to Mavericks, every time I create a multicam clip on FCPX, random files(that were used to make the multicam clip) become modified and unusable(in High Quality). Is there anything I can do to prevent this?
    I've tried transcoding, creating proxy media, creating optimized media, plus I've tried none of the above. Thing is, no matter what I do, it still happens(to random files) "after" I make the multicam clip. Is there a setting or something that was accidentally enabled by me or the upgrade?
    BTW: Everything seems to work fine when 'playback' is set to proxy. The problem is when I'm ready to export and switch 'playback' to High Quality.

    I had this same issue! But fixed it by going into the finder, finding the event, and delted the files out of the "High Quality Media." My project then refreshed to normal and no red modified file slides. The cool part: I din't even shut fcpx down to mess with the files in the finder. It all worked like a charm.
    Good luck!

  • Pages is not saving document correctly.  After saving the changes either do not appear or you can not open the file. The error is "not a valid format"  I am in Pages '09 4.1 (923).  I also use Parallels.  Anyone having similar issues?

    Pages is not saving document correctly.  After saving the changes either do not appear or you can not open the file. The error is "not a valid format"  I am in Pages '09 4.1 (923).  I also use Parallels.  Anyone having similar issues?

    I'm not sure that Lion AutoSave feature apply to network servers.
    I'm just sure that the Versions feature doesn't.
    Yvan KOENIG (VALLAURIS, France) samedi 21 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My Box account  is : http://www.box.com/s/00qnssoyeq2xvc22ra4k
    My iDisk is : http://public.me.com/koenigyvan

  • I am trying to transfer files from MacBook Pro to new MacBook air using Migration assistant via WiFi connection - the two computers can't seem to find each other

    I am trying to transfer files from MacBook Pro to new MacBook air using Migration assistant via WiFi connection - the two computers can't seem to find each other.
    Any ideas?
    Barry

    Try this article - http://support.apple.com/kb/HT4889.
    If it doesn't help, post back in this thread.
    Best of luck,
    Clinton

  • "Can't open illustration.  File is locked or in use.  ID = -54"

    "Can't open illustration.  File is locked or in use.  ID = -54" shows up when I try to install the Ai2Canvas.aip plugin on my Macbook Pro.  I'm using Illustrator CS5.  What do I have to do to make this plugin work?

    This one should be the CS5 one http://visitmix.com/labs/ai2canvas/

  • Can't open Illustrator after update error 16

    Adobe did an automatic update and since I can not open illustrator or any adobe program.
    tells me uninstall then reinstall and gives me error code 16, anything else I can do, or a reason it did this?
    thanks

    i,
    You could try to reinstall using the full three step way:
    Uninstall, run the Cleaner Tool, and reinstall.
    http://www.adobe.com/support/contact/cscleanertool.html

  • Giving old ipad to partner after using it for six months.  Icloud, FaceTime and store Apple Id revised no problem. I'd like to change my iMessage user id too.  It won't let me.  Anyone know how?

    Giving old ipad to partner after using it for six months.  Icloud, FaceTime and store Apple ID revised no problem. I'd like to change my iMessage user id too.  It won't let me.  Anyone know how?

    Look at this link.
    Giving your former iPad to a spouse or family member: the quick guide
    http://www.tuaw.com/2012/03/17/giving-your-former-ipad-to-a-spouse-or-family-mem ber-the-quick/
     Cheers, Tom

  • HT4946 i have been taken a backup but when i become to restore after update i found the backup corrupted and can't restore

    i have been taken a backup but when i become to restore after update i found the backup corrupted and can't restore

    unable to update or restore http://support.apple.com/kb/HT1808

  • Can't open illustration. cs4(eng)--- cc(eng)

    The AI files that I made with illustrator cs4(english ver.) is not open after I upgrade to Illustrator cc(english ver.) the file is totally broken.
    ( error message : can't open illustration )
    So I uninstall CC and reinstall to CC(korean ver.) . Then all files are open.
    what is the problem..... I used to work with english ver. so korean ver. is uneasy. ( translation is so weird !!!)
    clearly!
    cs4(eng.)------->cc(eng) ------>X (can't open illustration)
    cs4(eng.)------->cc(korean.)--------> O
    I want to work wit english version!
    please help me.!

    iag,
    You may start looking at recovery methods as the ones described in these links (although the cases dealt with differ form yours, you may do something similar):
    http://helpx.adobe.com/illustrator/kb/troubleshoot-damaged-illustrator-files.html
    http://helpx.adobe.com/illustrator/kb/opening-illustrator-file-get-error.html
    http://helpx.adobe.com/illustrator/kb/enable-content-recovery-mode-illustrator.html
    http://daxxter.wordpress.com/2009/04/16/how-to-recover-a-corrupted-illustrator-ai-file/
    It is difficult work, but it may be worth it.
    Working with the code, one specific way is to create a new empty document and create some very simple artwork in a copy of it (to see where the actual contents go), then move code from the corrupt file into the empty document and see what may be recovered that way.
    Hopefully, this will appear less woolly once you start on it.
    Edit: almost an hour after midnight here so I have to attend to other duties. The very best of luck.

  • After updating to 4.0 stable today, FF reports it is in offline mode and can't open pages! I've checked the work offline boolean in about:config, it is set to false as it should be. !?!?

    After updating to 4.0 stable today, FF reports it is in offline mode and can't open pages! I've checked the work offline boolean in about:config, it is set to false as it should be. !?!?

    What in particular didn't you like about Firefox 6?
    You can undo a lot of changes, either via changing settings or prefs on the <b>about:config</b> page or via extensions.
    *https://support.mozilla.com/kb/common-questions-after-updating-firefox
    Do a clean reinstall of the version that you want to use.
    Download a fresh Firefox copy and save the file to the desktop.
    *Firefox 3.6.x: http://www.mozilla.com/en-US/firefox/all-older.html
    *Firefox 6.0.x: http://www.mozilla.com/en-US/firefox/all.html
    * Uninstall your current Firefox version.
    * Do not remove personal data when you uninstall the current version or you lose your bookmarks and other data in the profile folder.
    Remove the Firefox program folder before installing that newly downloaded copy of the Firefox installer.
    * It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    Your bookmarks and other profile data are stored elsewhere in the Firefox Profile Folder and won't be affected by a reinstall, but make sure that you do not select to remove personal data if you uninstall Firefox.
    * http://kb.mozillazine.org/Profile_folder_-_Firefox
    * http://kb.mozillazine.org/Profile_backup

  • Can't open illustration. This illustration contains an illegal operand

    I opened a file i was working on for some days now, and i got this MSG??
    Can’t open illustration. This illustration contains an illegal operand.
    ((( /Real (xmlnode-nodevalue) ,
    %_(width) /String (xmlnode-nodename) ,
    %_; (width) ,
    %_/XMLNode :
    %_/Dictionary :
    %_; (xmlnode-attributes) ,
    %_/Array :
    %_; (xmlnode-children) ,
    %_2 /Int (xmlnode-nodetype) ,
    %_32262.3633 /Real (xmlnode-nodevalue) ,
    %_(hei %0JG1> 1b^UA3&!$E2)
    ANY HELP PLZ
    I use illustrator CS6
    OSX 10.9.1

    n.zeineddine,
    The message means that the file has been corrupted.
    Unless someone recognizes the actual error in the code, it may be difficult.
    One firct thing to try is to create a new document and File>Place the corrupt file in it, if possible, and see how much artwork is rescued that simple way.
    Or you could go the longer way of rebuilding, if possible.
    There are some instructions to follow,
    http://daxxter.wordpress.com/2009/04/16/how-to-recover-a-corrupted-illustrator-ai-file/
    http://kb2.adobe.com/cps/500/cpsid_50031.html
    http://kb2.adobe.com/cps/500/cpsid_50032.html
    http://helpx.adobe.com/illustrator/kb/troubleshoot-damaged-illustrator-files.html
    You you can try/buy a ready made solution,
    http://www.recoverytoolbox.com/buy_illustrator.html
    http://markzware.com/adobe-software/fix-illustrator-file-unknown-error-occurred-pdf2dtp-fi le-recovery/

  • Just installed OS Yosemite, and now I can't open Illustrator CS6. Asks me to update my Java, but I check and my Java is up to date. Please help!

    Just installed OS Yosemite, and now I can't open Illustrator CS6. Asks me to update my Java, but I check and my Java is up to date. Please help!

    Some people have reported reinstalling the Apple 2014-001 Java update has helped.
    See thread 7 here  Illustrator CC 2014 crashes on startup after Yosemite 10.10 upgrade today.

Maybe you are looking for

  • [SOLVED] Samba Issue (Arch+Win8 workgroup)

    Hi everyone. It`s been like 3 months that I am trying to add my archlinux VM to my windows network. I have even used arch as my main box but i changed cuz I couldnt share anything. I just created a workgroup in my windows 8 box and it gave me a passw

  • Import .par file into NWDS and Rum it without deploying ?

    Hello All, I'm new to the NWDS and the Portal. I've many Qns on my Requirement. Hope u guys can help me out in resolving my Issues. Is this  the right forum to place my Query ? If not then please let me know the right forum . My Requirement is like t

  • LOV with subselect shows return_value instead of display_value

    Hi, I have the following dynamic SQL based LOV with a union in it that does not display correctly in the application. SELECT role_name d, role_seq r FROM apex_app_roles ar WHERE security_level = 1 AND :F2500_APP_USER in (SELECT au.user_id FROM apex_a

  • ABBA Gold Album split into 2 Albums since with 11.4(18) update

    Strange things happen, with a click on the Album (ABBA Gold latest) it split up into 2 Albums one with only the 1. Song and one with the rest. I tried to delete it locally and download from the cloud again, but when I choose to view the "music" in th

  • 8830 and Video downloads...

    Hey folks, New to BB. Just got mine a few weeks ago. Have a 4GB microSD and have successfully transfered mp3 and pix to my BB and view/listened to them on BB. Where can I get some good video...movies, TV shows, etc that are in the right format for BB