I need some help of figuring why Illustrator CC hangs with my loops
This is a loop copying and exporting a list of GroupItems to SVG (workaround the limitation of artboards or slices)
And i have a progressbar for the process. But but....
After 2-3 successful progress window updates, a blue circle will start spinning and both App and my progress window will stop responding.
Script will continue working and console outputs shows ok as well. everything recovers after exporting finishes.
Anything wrong below? of course this is not a biggy since everything still works in background, but kinda of scary even though i am used to it with this App
function save2svg(){//export all found icons to svg, var d=confirm("Export "+ allIcons.length + " icons to svg format? "); if (d==true){ var newSpot = new File(docPath+"/svg/icons"); var tgtFolder = newSpot.saveDlg("Select the folder for exporting:") docPath =(tgtFolder.path!=null)? tgtFolder.path:docPath; var newDoc; var icon; var iconCopy; var fileSpec; var type = ExportType.SVG; var exportOptions = new ExportOptionsSVG(); exportOptions.embedRasterImages = false; exportOptions.embedAllFonts = false; //progress UI start var w = new Window ('palette','Exporting please wait!'); w.pbar = w.add ('progressbar', {x:20, y:12, width:300, height:12}, 0, allIcons.length); w.pbar.preferredSize = [300,20]; w.prompt = w.add("statictext",{x:10, y:0, width:320, height:20}, ''); w.prompt.justify = 'center'; w.show(); //progress UI end for ( var i = 0 ; i < allIcons.length ; i++){ //progress updating w.pbar.value = i+1; w.prompt.text = i+1+': '+ icon.iname; w.update(); //progress updating end icon = allIcons[i]; //each icon here is an object from list[content:groupItem, w:int, h:int, iname:string ] icon.iname = (icon.iname=="")? "icon"+i:icon.iname; newDoc=app.documents.add(DocumentColorSpace.RGB, icon.w, icon.h, 1); newDoc.title = icon.iname; iconCopy=icon.content.duplicate (newDoc, ElementPlacement.PLACEATEND); iconCopy.top =icon.h; iconCopy.left =0; filePath = new File(docPath+"/"+icon.iname); newDoc.exportFile( filePath, type, exportOptions ); newDoc.close (SaveOptions.DONOTSAVECHANGES); $.writeln("file exported: "+icon.iname); newDoc = null; } w.close(); } }