Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all 12845 articles
Browse latest View live

dynamic action does not working in palate button script

$
0
0

Hi Friend's

 

My dynamic action does not work in palette button option but it is working in dialog option. i need to know what is the issues going on my script. kindly help to complete this script

 

Button Palette script:

 

#target illustrator-21
#targetengine main

var win = new Window('palette', '');  
var tpanel = win.add ("tabbedpanel");  
tpanel.alignChildren = ["fill", "fill"];  
tpanel.preferredSize = [100,20];  
win.margins = 0;  
win.spacing = 0;  
var subtab1panel = tpanel.add ("tab", undefined, "Diadeis Script Panel");  
subtab1panel.orientation="row";  
subtab1panel.alignChildren = ["fill", "fill"];      
var t1group = subtab1panel.add("group");  
t1group.orientation = "row";  
t1group.alignChildren = ["fill", "fill"];  

var pfad = "/Applications/Diadeis Scripts/"      
var btnSelect1 = t1group.add('button', undefined, 'Ai Compare Zoom');  
var scriptToLoad1 =  function()    {        var callFunction = matchZoom +  '\rmatchZoom();';        btMessaging( 'illustrator', callFunction );    }   


function matchZoom() 
{
    var doc0= app.activeDocument;    var zoom = doc0.activeView.zoom;    var ctrPoint = doc0.activeView.centerPoint;    var idoc;        if (app.documents.length>1) {        for (var d=1; d<app.documents.length; d++) {            idoc = app.documents[d];            idoc.activeView.zoom = zoom;            idoc.activeView.centerPoint = ctrPoint;        }    }
}

function btMessaging( target, callFunction ) {
    var bt = new BridgeTalk();    bt.target = target;    bt.body = callFunction;    bt.send();
}  
var btnSelect2 = t1group.add('button', undefined, 'CTC');   
var scriptToLoad2 = new File(pfad+"CTC.jsx");     
var btnSelect3 = t1group.add('button', undefined, 'CTC (for Ferrero)');   
var scriptToLoad3 = new File(pfad+"CTC_Ferrero.jsx");

var btnSelect4 = t1group.add('button', undefined, 'CLD Automation');   
var scriptToLoad4 = new File(pfad+"VariableImporter.jsx");     
btnSelect1.onClick = scriptToLoad1;      
btnSelect2.onClick = function(){           var des = scriptToLoad2;     des.open("r");              var bt = new BridgeTalk;     bt.target = "illustrator";              var script = des.read();     des.close();                   bt.body = script;     bt.send();    
}// end function      btnSelect3.onClick = function(){           var des = scriptToLoad3;     des.open("r");              var bt = new BridgeTalk;     bt.target = "illustrator";              var script = des.read();     des.close();                   bt.body = script;     bt.send();    
}// end function     btnSelect4.onClick = function(){           var des = scriptToLoad4;     des.open("r");              var bt = new BridgeTalk;     bt.target = "illustrator";              var script = des.read();     des.close();                   bt.body = script;     bt.send();    
}// end function  

win.center();  
win.show();

 

Example linked script:

//////////////////////////////////////////////////////////////////////////////////////
//This script will generate a Live Ai file and CTC Ai file.                                                            //
// Display dialog events : Live Rasterize Effect Setting, Check Spelling, Launch Workflow.          //
//Cleanup Process : Unused Graphics Style, Unused Swatches,  Unsed Symbol.                           //
// Version : 1.0                                                                                                                  //
///////////////////////////////////////////////////////////////////////////////////

if ( app.documents.length == 1 )

{
// Rasterize Effect Setting 
app.executeMenuCommand('Live Rasterize Effect Setting'); 

//Unlock ("Background",  "Artwork") Layers
var aDoc = app.activeDocument;  
var myLayers = aDoc.layers;  
var actName = ("Background");  
try {      aDoc.activeLayer = myLayers.getByName (actName);      redraw();      actLayer = aDoc.activeLayer;      actLayer.locked = false;      actLayer.visible = true;      redraw();      }  
catch (e) {      alert ("Layer "+actName+" not found")      } 

var aDoc = app.activeDocument;  
var myLayers = aDoc.layers;  
var actName = ("Artwork");  
try {      aDoc.activeLayer = myLayers.getByName (actName);      redraw();      actLayer = aDoc.activeLayer;      actLayer.locked = false;      actLayer.visible = true;      redraw();      }  
catch (e) {      alert ("Layer "+actName+" not found")      } 

// Check Spelling  
app.executeMenuCommand('Check Spelling'); 

// Check Find and Replace  
app.executeMenuCommand('Find and Replace'); 

// Link Replace 
function linkReplacer() {       var orginalUIL = app.userInteractionLevel;       app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;       if (app.documents.length == 0) {            alert('Please have an "Illustrator" document open before running this script.');            return;       } else {            docRef = app.activeDocument;       }                var defaultFolder = new Folder (Folder(app.activeDocument.path + '/../040 Images/043 High Res'));       var psdFolder = defaultFolder;       if (psdFolder == null) return;              with (docRef) {            var placedFiles = new Array();            for (var i = 0; i < placedItems.length; i++) {                 placedFiles.push(placedItems[i].file.name);            }                        for (var j = 0; j < placedItems.length; j++) {                 var rePlace = new File(psdFolder.fsName + '/' + placedFiles[j]);                 if (rePlace.exists) {                      placedItems[j].file = rePlace;                 } else {                      alert('File "' + placedFiles[j] + '" is missing?');                 }            }       }       app.userInteractionLevel = orginalUIL;  
}      linkReplacer(); 

//Unlock all Layers
function unlockedSubLayers ( layers ) {      var i = layers.length;      if ( i ) {          while ( i-- ) {              layers[i].locked = false;              unlockedSubLayers( layers[i].layers );          }      }  
}  
unlockedSubLayers( activeDocument.layers );

//Empty text boxes are removed
app.executeMenuCommand('cleanup menu item');  

//Lock all Layers
function lockedSubLayers ( layers ) {      var i = layers.length;      if ( i ) {          while ( i-- ) {              layers[i].locked = true;              lockedSubLayers( layers[i].layers );          }      }  
}  
lockedSubLayers( activeDocument.layers );


//Cleanup Dynamic Action
 function createAction ( actionString, set ) {                    var fpath = Folder ( "~/Desktop/" )          var f = File ( fpath + set + '.aia' );                    f.open( 'w' );          f.write( actionString );          f.close();          app.loadAction( f );          f.remove();       } 

function runActionScript(){            var set = 'Cleanup';            var action = 'Delete Unused Panel Items';                    var actionString = [            
"/version 3",
"/name [ 7",
"    436c65616e7570",
"]",
"/isOpen 0",
"/actionCount 1",
"/action-1 {",
"    /name [ 25",
"        44656c65746520556e757365642050616e656c204974656d73",
"    ]",
"    /keyIndex 0",
"    /colorIndex 0",
"    /isOpen 1",
"    /eventCount 12",
"    /event-1 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_symbol_palette)",
"        /localizedName [ 7",
"            53796d626f6c73",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 4294967295",
"            /type (enumerated)",
"            /name [ 17",
"                53656c65637420416c6c20556e75736564",
"            ]",
"            /value 12",
"        }",
"    }",
"    /event-2 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_symbol_palette)",
"        /localizedName [ 7",
"            53796d626f6c73",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 4294967295",
"            /type (enumerated)",
"            /name [ 13",
"                44656c6574652053796d626f6c",
"            ]",
"            /value 5",
"        }",
"    }",
"    /event-3 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_stop)",
"        /localizedName [ 4",
"            53746f70",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 1",
"        /parameterCount 2",
"        /parameter-1 {",
"            /key 1952807028",
"            /showInPalette 0",
"            /type (ustring)",
"            /value [ 0",
"",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1668247156",
"            /showInPalette 4294967295",
"            /type (boolean)",
"            /value 1",
"        }",
"    }",
"    /event-4 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_styles)",
"        /localizedName [ 14",
"            47726170686963205374796c6573",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 17",
"                53656c65637420416c6c20556e75736564",
"            ]",
"            /value 14",
"        }",
"    }",
"    /event-5 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_styles)",
"        /localizedName [ 14",
"            47726170686963205374796c6573",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 12",
"                44656c657465205374796c65",
"            ]",
"            /value 3",
"        }",
"    }",
"    /event-6 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_stop)",
"        /localizedName [ 4",
"            53746f70",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 1",
"        /parameterCount 2",
"        /parameter-1 {",
"            /key 1952807028",
"            /showInPalette 0",
"            /type (ustring)",
"            /value [ 0",
"",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1668247156",
"            /showInPalette 4294967295",
"            /type (boolean)",
"            /value 1",
"        }",
"    }",
"    /event-7 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_brush)",
"        /localizedName [ 5",
"            4272757368",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 17",
"                53656c65637420416c6c20556e75736564",
"            ]",
"            /value 8",
"        }",
"    }",
"    /event-8 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_brush)",
"        /localizedName [ 5",
"            4272757368",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 12",
"                44656c657465204272757368",
"            ]",
"            /value 3",
"        }",
"    }",
"    /event-9 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_stop)",
"        /localizedName [ 4",
"            53746f70",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 1",
"        /parameterCount 2",
"        /parameter-1 {",
"            /key 1952807028",
"            /showInPalette 0",
"            /type (ustring)",
"            /value [ 0",
"",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1668247156",
"            /showInPalette 4294967295",
"            /type (boolean)",
"            /value 1",
"        }",
"    }",
"    /event-10 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_swatches)",
"        /localizedName [ 8",
"            5377617463686573",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 17",
"                53656c65637420416c6c20556e75736564",
"            ]",
"            /value 11",
"        }",
"    }",
"    /event-11 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_swatches)",
"        /localizedName [ 8",
"            5377617463686573",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 13",
"                44656c65746520537761746368",
"            ]",
"            /value 3",
"        }",
"    }",
"    /event-12 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_stop)",
"        /localizedName [ 4",
"            53746f70",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 1",
"        /parameterCount 2",
"        /parameter-1 {",
"            /key 1952807028",
"            /showInPalette 0",
"            /type (ustring)",
"            /value [ 0",
"",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1668247156",
"            /showInPalette 4294967295",
"            /type (boolean)",
"            /value 1",
"        }",
"    }",
"}"          ].join( "\n" );            createAction( actionString, set );            app.doScript( action, set );            app.unloadAction( set, "" );        }  

runActionScript();
    



//recurse Layers
function recurseLayers( objArray ) {                for ( var i = 0; i < objArray.length; i++ ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var v = objArray[i].visible;                      if ( !v ) objArray[i].visible = true;                              // Recurse the contained layer collection                      if ( objArray[i].layers.length > 0 ) {                                recurseLayers( objArray[i].layers )                      }                          // Recurse the contained group collection                      if ( objArray[i].groupItems.length > 0 ) {                                recurseGroups( objArray[i].groupItems )                      }                           // Return to previous values                      objArray[i].locked = l;                      objArray[i].visible = v;            }  
};    
function recurseGroups( objArray ) {                for ( var i = 0; i < objArray.length; i++ ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var h = objArray[i].hidden;                      if ( h ) objArray[i].hidden = false;                              // Recurse the contained group collection                      if ( objArray[i].groupItems.length > 0 ) {                                recurseGroups( objArray[i].groupItems )                      }                           // Return to previous values                      objArray[i].locked = l;                      objArray[i].hidden = h;            }  
};  



// populate Live file.
for ( i = 0; i < app.documents.length; i++ ) {    var workingDoc = app.documents[i];       var workingDocFile = workingDoc.fullName;            var aiFile = new File(workingDocFile.toString());           workingDoc.saveAs(aiFile);     }

// Text to Outline
function outlineDocText(  ) {              if ( app.documents.length == 0 ) return;        var docRef = app.activeDocument;                recurseLayers( docRef.layers );      
};    
outlineDocText();   



//recurse Layers
  
function recurseLayers( objArray ) {                for ( var i = 0; i < objArray.length; i++ ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var v = objArray[i].visible;                      if ( !v ) objArray[i].visible = true;                          outlineText( objArray[i].textFrames );                          // Recurse the contained layer collection                      if ( objArray[i].layers.length > 0 ) {                                recurseLayers( objArray[i].layers )                      }                          // Recurse the contained group collection                      if ( objArray[i].groupItems.length > 0 ) {                                recurseGroups( objArray[i].groupItems )                      }                           // Return to previous values                      objArray[i].locked = l;                      objArray[i].visible = v;            }  
};    
function recurseGroups( objArray ) {                for ( var i = 0; i < objArray.length; i++ ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var h = objArray[i].hidden;                      if ( h ) objArray[i].hidden = false;                          outlineText( objArray[i].textFrames );                          // Recurse the contained group collection                      if ( objArray[i].groupItems.length > 0 ) {                                recurseGroups( objArray[i].groupItems )                      }                           // Return to previous values                      objArray[i].locked = l;                      objArray[i].hidden = h;            }  
};    



function outlineText( objArray ) {                // Reverse this loop as it brakes the indexing            for ( var i = objArray.length-1; i >= 0; i-- ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var h = objArray[i].hidden;                      if ( h ) objArray[i].hidden = false;                          var g = objArray[i].createOutline(  );                          // Return new group to previous Text Frame values                      g.locked = l;                      g.hidden = h;                }    
}; 


// Menu Command of Find Font 
app.executeMenuCommand('Adobe Illustrator Find Font Menu Item'); 

// populate CTC file.

for ( i = 0; i < app.documents.length; i++ ) {    var workingDoc = app.documents[i];       var workingDocFile = workingDoc.fullName;            var aiFile = new File(workingDocFile.toString().replace(".ai","_CTC.ai"));           workingDoc.saveAs(aiFile);     }                
for ( i = 0; i < app.documents.length; i++ ) {    var workingDoc = app.documents[i];       var workingDocFile = workingDoc.fullName;            var aiFile = Folder (File(workingDocFile.toString().replace("_CTC.ai",".ai")));           app.open (aiFile);     }

 //Launch Workflow Dynamic Action
 function createAction1 ( actionString, set ) {                    var fpath = Folder ( "~/Desktop/" )          var f = File ( fpath + set + '.aia' );                    f.open( 'w' );          f.write( actionString );          f.close();          app.loadAction( f );          f.remove();       } 

function runActionScript1(){            var set = 'diadeis';            var action = 'Launch Workflow';                    var actionString = [            
"/version 3",
"/name [ 7",
"    64696164656973",
"]",
"/isOpen 1",
"/actionCount 1",
"/action-1 {",
"    /name [ 15",
"        4c61756e636820576f726b666c6f77",
"    ]",
"    /keyIndex 0",
"    /colorIndex 0",
"    /isOpen 0",
"    /eventCount 1",
"    /event-1 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_commandManager)",
"        /localizedName [ 16",
"            416363657373204d656e75204974656d",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 3",
"        /parameter-1 {",
"            /key 1769238125",
"            /showInPalette 4294967295",
"            /type (ustring)",
"            /value [ 18",
"                4c61756e636820576f726b666c6f772e2e2e",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1818455661",
"            /showInPalette 4294967295",
"            /type (ustring)",
"            /value [ 15",
"                4c61756e636820576f726b666c6f77",
"            ]",
"        }",
"        /parameter-3 {",
"            /key 1668114788",
"            /showInPalette 4294967295",
"            /type (integer)",
"            /value 2164260958",
"        }",
"    }",
"}"            ].join( "\n" );            createAction( actionString, set );            app.doScript( action, set );            app.unloadAction( set, "" );        }  

runActionScript1();

alert('Completed');
}
             else              {                               alert('Multiple Artworks are opened.\n Close all other reference files \n Expect Final artwork file');                  !  }

Thanks and regards.

Kalaimani.S


Send e-mail via JavaScript?

$
0
0

Hi all

 

I've written a script that processes an Illustrator file, then, as a final result, exports PDFs to a specific folder. Everything looking fine up to here. My code created almost 500 PDFs correctly.

 

The question is the following:

 

For each loop inside my script, I have a variable (called "myFile"), especifically a File object, that is exactelly my outputted PDF file.

 

I also have a variable (called "mail") especifically a string, that has stored an e-mail adress (this adress changes for each PDF).

 

I'd like, If possible, to send "myFile" to the e-mail stored in the "mail" variable.

 

I looked at Illustrator JavaScript reference and also to the JavaScript Tools Guide, but did not find any object or any way to do that.

 

Is there any way to send files, this case PDFs, created via Illustrator scripting, by e-mail???

 

P.s.: I also thought perhaps I could use BridgeTalk object to send the message/task to other Adobe Application to send this e-mail, but I really do not know If there's any Adobe Application that has an object or method to send e-mail via JavaScript (at least Photoshop and InDesign could not do that, If I remember well, and I did not find any way to target Acrobat in order to try this).

 

Any suggestion?

 

Thank you very much

Can't write to network drive (osx)

$
0
0

I've been running a script for a while now that saves to a network share, but today it's just stopped working.  I just get an error "Can't save the illustration.  You do not have enough access privileges. -5000".  The drive in question has never changed, can be written to as normal from and File /Save As... dialog or adding files with Finder, but the script can no longer write to the drive.

 

Have checked the permissions for the drive its all full access & writable, i'm out of ideas!

 

My script longer, but get the same error with this more simple one:

 

 

function saveAsAI8()       {       if (app.documents.length == 0) return;              // Set a variable to the active document       var docRef = app.activeDocument;              // Check and strip off old extension        var docName = docRef.name;       var nameString = '';       var extOffset = docName.lastIndexOf('.');       if (extOffset == -1) {            nameString = docName;       } else {            nameString = docName.substr(0, extOffset);       }         // Get the name to the files parent  
//     var docPath = docRef.path.fsName;    var docPath= "/Print Jobs/";    //  var docPath = "~/Desktop/";             // Set up a save options object       var epsOptions = new EPSSaveOptions();       epsOptions.cmykPostscript = true;       epsOptions.compatability = Compatibility.ILLUSTRATOR8;       epsOptions.compatibleGradientPrinting = true;       epsOptions.embedAllFonts = true;       epsOptions.embedLinkedFiles = true;       epsOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;       epsOptions.includeDocumentThumbnials = true;       epsOptions.overprint = PDFOverprint.PRESERVEPDFOVERPRINT;       epsOptions.postScript = EPSPostScriptLevelEnum.LEVEL2;       epsOptions.preview = EPSPreview.COLORTIFF;              // Make file object to new location       var saveFile = new File(docPath+'/TEST.eps');              // Use save as method passing new file path & options       docRef.saveAs(saveFile, epsOptions);       }         
saveAsAI8();  

Random brush stroke

$
0
0

I download this script that randomly fill all selected paths with the selected swatches:

 

mySelection = app.activeDocument.selection;
myDoc = app.activeDocument;
if (mySelection instanceof Array)
{
selSwatches = myDoc.swatches.getSelected();

if(selSwatches.length != 0)
for (i=0; i<mySelection.length; i++)
{
if(mySelection[i].typename == "PathItem" || mySelection[i].typename == "CompoundPathItem")
{
selItem = mySelection[i];
selItem.filled = true;


swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

if(selItem.typename == "PathItem")
selItem.fillColor = selSwatches[swatchIndex].color;
else
selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;

}
}
}

 

I would like to adapt it to stroke randomly with all selected brushes

 

adding/loading a script in an action

$
0
0

hi all

 

i'm not familiar with scripts at all and a quick search didnt result much in similar question except one from 8yrs ago which said it cant, but maybe since then there were some changes.

 

is it possible to include a script in the action?

i've tried recording an action and loaded the script but didnt show up. i'm afraid it still can't but maybe theres a work around?

 

the script im using basically searches for paths smaller than x length, which takes ages to run for complex images, and i need to do it on way too many images to do one by one, so i was hoping for some automation.

 

cheers

JS select all almost equal shapes to selected one. Why it affects only on paths but not on compound paths?

$
0
0

Hi guys!

 

I'm new in JS and wrote a script for selection of all almost equal shapes (by size) to the one I select before running a script. I work with svg files mostly and precision of dimensions varies depending on many things, shapes which look like equal are not those and have very small difference like 0.005 px in length or width/height.

I know about existent script SelectPathsBySize but it's too heavy (works really slow) and doesn't fit to my needs. So I decided to write my own.

It works well on paths (when some path is selected script selects all almost equal path in my design) but when I select compound path the script returns nothing (given there are many almost equal compound paths in the design).

Here is the script:

 

var myDoc = app.activeDocument; 

var shape = app.activeDocument.selection[0];

 

for (i=0 ; i< myDoc.pageItems.length; i++) 

     { 

  var allShapes = myDoc.pageItems[i] 

  var diff = Math.abs( shape.length - allShapes.length )

  var diff2 = Math.abs( shape.width - allShapes.width );

          if( diff < 0.015 && diff2 < 0.01 )

                         allShapes.selected = true; 

                    } 

     } 

 

app.redraw();

 

I'd be very appreciated for any tips/suggestions how to make it work for compound paths as well.

Thanks in advance!

KIT NUMBERING IN ORDER

$
0
0

Hi,

 

Really hoping someone out there can help. Currently I number these kits manually with hundreds to contend with and I am desperately seeking an easier way. I have found a script that is like a colouring book effect which works but I really need to number from bottom to top left to right. I have tried to show some sort of example below.

 

The link below is for a pdf with the sort of work I need numbering.

Adobe Document Cloud

NUMBERING.jpg

I really appreciate every bit of help I get with this. I may even be able to get a pay rise with this!!! If I do I will send a reward!!!

 

Thanks

RKG

save each layers and sublayers to image (png) javascript

$
0
0

Hi guys, i just want to ask if theres a javascript that would save each or all layers and sublayer to image. I found some in the internet but that would only save the outer layers, but what i want was to save all layers (layers within a layer). I have been having a lot of problems in this one for the past few days.


Align to bottom selection?

$
0
0

I edited a script from this forum (I think originally written by williamadowling) to align selection to bottom object. I want to modify it to add the "Bottom Object" to the selection by name so the user does not need to manually select it. The modification works… if I run the script twice. What am I doing wrong?

 

The starting selection is the "fingerprint" group. Here's a simplified AI file if it's helpful.

 

Thanks for your help.

 

var docRef = app.activeDocument;      var sel = docRef.selection;    var AlignObj = docRef.pageItems.getByName("PrintAlign");    AlignObj.selected = true;        function alignToObj()  
{      var keyCenter = getCenterPoint(AlignObj);     var curItem,curCenter;     const ALIGNMENT_PREFERENCE_VERTICAL = true;      const ALIGNMENT_PREFERENCE_HORIZONTAL = true;        for(var x=0, len = sel.length-1; x < len; x++)      {          curItem = sel[x];          if(ALIGNMENT_PREFERENCE_HORIZONTAL)          {              //align the object horizontally              curItem.left = keyCenter.h - curItem.width/2;          }          if(ALIGNMENT_PREFERENCE_VERTICAL)          {              //align the object vertically              curItem.top = keyCenter.v + curItem.height/2;          }      }      function getCenterPoint(item)      {          return {"h":item.left + item.width/2, "v":item.top - item.height/2};      }  
}  
alignToObj();  

Anything similar to javascript's setInterval in ExtendScript?

$
0
0

I need a way to poll my server for new jobs for the illustrator script to work on every few hours.

I tried with $.sleep(), but that is blocking, I need a non-blocking way to do this.

Any advice?

 

Thanks!

Kashmira

How can delete a composite font?

$
0
0

I want delete composite font exist in Illustrator

I had try this code, but occur error: Public member 'Delete' on type 'TextFont' not found.

               Dim iFontNum =oIllustrator.TextFonts.Count

                For iFontNo = iFontNum To 1 Step -1

                    Try

                        Dim oFont = oIllustrator.TextFonts(iFontNo)

                        Dim strName = oFont.Name

                        If Left(strName, 4) = "ATC-" Then

                           oIllustrator.TextFonts(iFontNo).Delete

                        End If

                    Catch ex As Exception

                    End Try

                Next

How can delete a composite font?

Thank you.

Please help to fix script that works perfectly on Ai 2015 but not perfect on Ai 2017

$
0
0

Dear all,

 

I have bellow script that i used on Ai 2015.

It's just for embed all linked images and no problem at all.

 

#target Illustrator

 

if ( app.documents.length > 0 ) { 

 

   while ( app.activeDocument.placedItems.length > 0 ) { 

  placedArt = app.activeDocument.placedItems[0]; 

  placedArt.embed(); 

   } 

}

 

But after I start to using Ai 2017, I got error as bellow. Not every time, but it happen a lot.

Is there anyone can help me to fix this?

 

I wish all of you have wonderful days.

Thank you.

Drawing a rectangle of exact size of the artboard?

$
0
0

Has anybody written a JS script to to draw a rectangle on an active document which would be exact size as the document's artboard?

I find it very inaccurate and cumbersome trying to draw such rectangle by hand.

 

Please let me know where such JS code can be found. I have not done any Illustrator scripting beyond the "Hello world".

 

Thanks

franK

Step and repeat

$
0
0
Is there an easy way to step and repeat with numerical off-sets in Illustrator CS3, Photoshop CS3, or InDesign (in OX 10.5) ?

Need a Script to batch Resize art and Artboard

$
0
0

I have about 3000 Illustrator assets with varying sizes that I need to batch resize to fit proportionally, along with their artboard, to 170 x170 pixels. Once they have been resized, I can pinpoint "problem images" through bridge and make further adjustments. I have poked around but not found any script that can accomplish this. A few seem to be in the general direction, but sadly my knowledge of scripting is severly limited. Can anyone help me with this?


How to add text in .ai file and set position, font, size and colour

$
0
0

I want to place multiple lines of of text (individually) into .ai file and set size, font, colour and position for each.

Preferably text should have origin in a single point (rather than be framed)

 

Hope anyone can help me out.

 

Thank you in advance.

Placing files/images

$
0
0

Sorry guys, but I an new in this... help me please!

 

How can I place any image or any file into my active document via JavaScript?

Not using actions or menu like: File > Place...

 

Is there a way to do it? Hope so :/

 

A big hug for your attention in advanced_

importPrintPreset, is it broken?

$
0
0

Hi everyone,

 

has anyone had any luck with importPrintPreset()? I can't get it to import any presets, I get no errors, it just doesn't do anything...

 

var idoc = app.activeDocument;


var file = new File('c:/temp/printPresetFile');
idoc.importPrintPreset ('presetName', file);

 

using CS5, win 7

Help with cleaning up array of pageItems, please.

$
0
0

Hey folks.

 

I have a question that only loosely pertains to illustrator, as I think I'm just missing something really obvious in basic JS logic..

 

I've written a script to create artboards for me that fit tight to the outside of many pageItems. In the first iteration, I wrote the script to look only for groupItems because I was assuming my production artists were doing things properly. Turns out, many of them 'walk to the beat of a different drummer', if you will. So I've decided to give up on changing their habits and take this as an exercise in self improvement with regards to scripting unpredictability.

 

Now I'm rewriting the script to work with any pageItem. The problem I'm running into is the exclusion of a pageItem that is either- A: Completely contained within another object, or B: Shares left && || top && || right && || bottom coordinates (eg. object a has bounds 5, 5, 10, -10 and object b has bounds 5, 4, 9, -9).

 

So far I have a function written to sort through the pageItems and sort them into rows (within a certain tolerance). After i determine all pageItems that are in a particular row, I want to loop that row to check for any items that are completely contained within another object, or share some bounds as the example above. The problem I'm running into is how to properly and efficiently do this check.. I've done this successfully when I'm only looking for something completely contained within, like this:

 

var array = [(all pageItems of given row are pushed here)]

for(a=array.length-1;a>-1;a--){     var curObj = array[a];     var L = curObj.left;     var T = curObj.top;     var R = L + curObj.width;     var B = T - curObj.height;     for(b=array.length-1;b>-1;b--){          var compareObj = array[b];          var CL = compareObj.left;          var CT = compareObj.top;          var CR = CL + compareObj.width;          var CB = CT - compareObj.height;          if(CL > L && CT < T && CR < R && CB > B){               array.splice(b,1);          }     }
}

 

This part works fine, but only because it returns false when a=b (since when a=b it's comparing the same object, so if I include >= or <=, it splices every object from the array and nothing happens).

 

So, my question is, how do I set up that second loop to ignore curObj? My first inclination is to simply splice the curObj before I start the second loop and set the compareObj variable. But there's a good chance that object needs to be compared later.

 

Sorry if that's confusing.. i've been pulling my hair out trying to wrap my head around this (probably really simple) issue.

 

**EDIT**

 

I made a quick visualization for what i'm looking to do. In the attached screenshot I want to loop through this row of objects and splice the black boxes out of the array while leaving the gray boxes.

 

Screen Shot 2015-08-12 at 8.58.55 AM.jpg

dynamic action does not working in palate button script

$
0
0

Hi Friend's

 

My dynamic action does not work in palette button option but it is working in dialog option. i need to know what is the issues going on my script. kindly help to complete this script

 

Button Palette script:

 

#target illustrator-21
#targetengine main

var win = new Window('palette', '');  
var tpanel = win.add ("tabbedpanel");  
tpanel.alignChildren = ["fill", "fill"];  
tpanel.preferredSize = [100,20];  
win.margins = 0;  
win.spacing = 0;  
var subtab1panel = tpanel.add ("tab", undefined, "Diadeis Script Panel");  
subtab1panel.orientation="row";  
subtab1panel.alignChildren = ["fill", "fill"];      
var t1group = subtab1panel.add("group");  
t1group.orientation = "row";  
t1group.alignChildren = ["fill", "fill"];  

var pfad = "/Applications/Diadeis Scripts/"      
var btnSelect1 = t1group.add('button', undefined, 'Ai Compare Zoom');  
var scriptToLoad1 =  function()    {        var callFunction = matchZoom +  '\rmatchZoom();';        btMessaging( 'illustrator', callFunction );    }   


function matchZoom() 
{
    var doc0= app.activeDocument;    var zoom = doc0.activeView.zoom;    var ctrPoint = doc0.activeView.centerPoint;    var idoc;        if (app.documents.length>1) {        for (var d=1; d<app.documents.length; d++) {            idoc = app.documents[d];            idoc.activeView.zoom = zoom;            idoc.activeView.centerPoint = ctrPoint;        }    }
}

function btMessaging( target, callFunction ) {
    var bt = new BridgeTalk();    bt.target = target;    bt.body = callFunction;    bt.send();
}  
var btnSelect2 = t1group.add('button', undefined, 'CTC');   
var scriptToLoad2 = new File(pfad+"CTC.jsx");     
var btnSelect3 = t1group.add('button', undefined, 'CTC (for Ferrero)');   
var scriptToLoad3 = new File(pfad+"CTC_Ferrero.jsx");

var btnSelect4 = t1group.add('button', undefined, 'CLD Automation');   
var scriptToLoad4 = new File(pfad+"VariableImporter.jsx");     
btnSelect1.onClick = scriptToLoad1;      
btnSelect2.onClick = function(){           var des = scriptToLoad2;     des.open("r");              var bt = new BridgeTalk;     bt.target = "illustrator";              var script = des.read();     des.close();                   bt.body = script;     bt.send();    
}// end function      btnSelect3.onClick = function(){           var des = scriptToLoad3;     des.open("r");              var bt = new BridgeTalk;     bt.target = "illustrator";              var script = des.read();     des.close();                   bt.body = script;     bt.send();    
}// end function     btnSelect4.onClick = function(){           var des = scriptToLoad4;     des.open("r");              var bt = new BridgeTalk;     bt.target = "illustrator";              var script = des.read();     des.close();                   bt.body = script;     bt.send();    
}// end function  

win.center();  
win.show();

 

Example linked script:

//////////////////////////////////////////////////////////////////////////////////////
//This script will generate a Live Ai file and CTC Ai file.                                                            //
// Display dialog events : Live Rasterize Effect Setting, Check Spelling, Launch Workflow.          //
//Cleanup Process : Unused Graphics Style, Unused Swatches,  Unsed Symbol.                           //
// Version : 1.0                                                                                                                  //
///////////////////////////////////////////////////////////////////////////////////

if ( app.documents.length == 1 )

{
// Rasterize Effect Setting 
app.executeMenuCommand('Live Rasterize Effect Setting'); 

//Unlock ("Background",  "Artwork") Layers
var aDoc = app.activeDocument;  
var myLayers = aDoc.layers;  
var actName = ("Background");  
try {      aDoc.activeLayer = myLayers.getByName (actName);      redraw();      actLayer = aDoc.activeLayer;      actLayer.locked = false;      actLayer.visible = true;      redraw();      }  
catch (e) {      alert ("Layer "+actName+" not found")      } 

var aDoc = app.activeDocument;  
var myLayers = aDoc.layers;  
var actName = ("Artwork");  
try {      aDoc.activeLayer = myLayers.getByName (actName);      redraw();      actLayer = aDoc.activeLayer;      actLayer.locked = false;      actLayer.visible = true;      redraw();      }  
catch (e) {      alert ("Layer "+actName+" not found")      } 

// Check Spelling  
app.executeMenuCommand('Check Spelling'); 

// Check Find and Replace  
app.executeMenuCommand('Find and Replace'); 

// Link Replace 
function linkReplacer() {       var orginalUIL = app.userInteractionLevel;       app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;       if (app.documents.length == 0) {            alert('Please have an "Illustrator" document open before running this script.');            return;       } else {            docRef = app.activeDocument;       }                var defaultFolder = new Folder (Folder(app.activeDocument.path + '/../040 Images/043 High Res'));       var psdFolder = defaultFolder;       if (psdFolder == null) return;              with (docRef) {            var placedFiles = new Array();            for (var i = 0; i < placedItems.length; i++) {                 placedFiles.push(placedItems[i].file.name);            }                        for (var j = 0; j < placedItems.length; j++) {                 var rePlace = new File(psdFolder.fsName + '/' + placedFiles[j]);                 if (rePlace.exists) {                      placedItems[j].file = rePlace;                 } else {                      alert('File "' + placedFiles[j] + '" is missing?');                 }            }       }       app.userInteractionLevel = orginalUIL;  
}      linkReplacer(); 

//Unlock all Layers
function unlockedSubLayers ( layers ) {      var i = layers.length;      if ( i ) {          while ( i-- ) {              layers[i].locked = false;              unlockedSubLayers( layers[i].layers );          }      }  
}  
unlockedSubLayers( activeDocument.layers );

//Empty text boxes are removed
app.executeMenuCommand('cleanup menu item');  

//Lock all Layers
function lockedSubLayers ( layers ) {      var i = layers.length;      if ( i ) {          while ( i-- ) {              layers[i].locked = true;              lockedSubLayers( layers[i].layers );          }      }  
}  
lockedSubLayers( activeDocument.layers );


//Cleanup Dynamic Action
 function createAction ( actionString, set ) {                    var fpath = Folder ( "~/Desktop/" )          var f = File ( fpath + set + '.aia' );                    f.open( 'w' );          f.write( actionString );          f.close();          app.loadAction( f );          f.remove();       } 

function runActionScript(){            var set = 'Cleanup';            var action = 'Delete Unused Panel Items';                    var actionString = [            
"/version 3",
"/name [ 7",
"    436c65616e7570",
"]",
"/isOpen 0",
"/actionCount 1",
"/action-1 {",
"    /name [ 25",
"        44656c65746520556e757365642050616e656c204974656d73",
"    ]",
"    /keyIndex 0",
"    /colorIndex 0",
"    /isOpen 1",
"    /eventCount 12",
"    /event-1 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_symbol_palette)",
"        /localizedName [ 7",
"            53796d626f6c73",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 4294967295",
"            /type (enumerated)",
"            /name [ 17",
"                53656c65637420416c6c20556e75736564",
"            ]",
"            /value 12",
"        }",
"    }",
"    /event-2 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_symbol_palette)",
"        /localizedName [ 7",
"            53796d626f6c73",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 4294967295",
"            /type (enumerated)",
"            /name [ 13",
"                44656c6574652053796d626f6c",
"            ]",
"            /value 5",
"        }",
"    }",
"    /event-3 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_stop)",
"        /localizedName [ 4",
"            53746f70",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 1",
"        /parameterCount 2",
"        /parameter-1 {",
"            /key 1952807028",
"            /showInPalette 0",
"            /type (ustring)",
"            /value [ 0",
"",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1668247156",
"            /showInPalette 4294967295",
"            /type (boolean)",
"            /value 1",
"        }",
"    }",
"    /event-4 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_styles)",
"        /localizedName [ 14",
"            47726170686963205374796c6573",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 17",
"                53656c65637420416c6c20556e75736564",
"            ]",
"            /value 14",
"        }",
"    }",
"    /event-5 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_styles)",
"        /localizedName [ 14",
"            47726170686963205374796c6573",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 12",
"                44656c657465205374796c65",
"            ]",
"            /value 3",
"        }",
"    }",
"    /event-6 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_stop)",
"        /localizedName [ 4",
"            53746f70",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 1",
"        /parameterCount 2",
"        /parameter-1 {",
"            /key 1952807028",
"            /showInPalette 0",
"            /type (ustring)",
"            /value [ 0",
"",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1668247156",
"            /showInPalette 4294967295",
"            /type (boolean)",
"            /value 1",
"        }",
"    }",
"    /event-7 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_brush)",
"        /localizedName [ 5",
"            4272757368",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 17",
"                53656c65637420416c6c20556e75736564",
"            ]",
"            /value 8",
"        }",
"    }",
"    /event-8 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_brush)",
"        /localizedName [ 5",
"            4272757368",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 12",
"                44656c657465204272757368",
"            ]",
"            /value 3",
"        }",
"    }",
"    /event-9 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_stop)",
"        /localizedName [ 4",
"            53746f70",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 1",
"        /parameterCount 2",
"        /parameter-1 {",
"            /key 1952807028",
"            /showInPalette 0",
"            /type (ustring)",
"            /value [ 0",
"",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1668247156",
"            /showInPalette 4294967295",
"            /type (boolean)",
"            /value 1",
"        }",
"    }",
"    /event-10 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_swatches)",
"        /localizedName [ 8",
"            5377617463686573",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 17",
"                53656c65637420416c6c20556e75736564",
"            ]",
"            /value 11",
"        }",
"    }",
"    /event-11 {",
"        /useRulersIn1stQuadrant 1",
"        /internalName (ai_plugin_swatches)",
"        /localizedName [ 8",
"            5377617463686573",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 0",
"        /parameterCount 1",
"        /parameter-1 {",
"            /key 1835363957",
"            /showInPalette 1",
"            /type (enumerated)",
"            /name [ 13",
"                44656c65746520537761746368",
"            ]",
"            /value 3",
"        }",
"    }",
"    /event-12 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_stop)",
"        /localizedName [ 4",
"            53746f70",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 1",
"        /showDialog 1",
"        /parameterCount 2",
"        /parameter-1 {",
"            /key 1952807028",
"            /showInPalette 0",
"            /type (ustring)",
"            /value [ 0",
"",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1668247156",
"            /showInPalette 4294967295",
"            /type (boolean)",
"            /value 1",
"        }",
"    }",
"}"          ].join( "\n" );            createAction( actionString, set );            app.doScript( action, set );            app.unloadAction( set, "" );        }  

runActionScript();
    



//recurse Layers
function recurseLayers( objArray ) {                for ( var i = 0; i < objArray.length; i++ ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var v = objArray[i].visible;                      if ( !v ) objArray[i].visible = true;                              // Recurse the contained layer collection                      if ( objArray[i].layers.length > 0 ) {                                recurseLayers( objArray[i].layers )                      }                          // Recurse the contained group collection                      if ( objArray[i].groupItems.length > 0 ) {                                recurseGroups( objArray[i].groupItems )                      }                           // Return to previous values                      objArray[i].locked = l;                      objArray[i].visible = v;            }  
};    
function recurseGroups( objArray ) {                for ( var i = 0; i < objArray.length; i++ ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var h = objArray[i].hidden;                      if ( h ) objArray[i].hidden = false;                              // Recurse the contained group collection                      if ( objArray[i].groupItems.length > 0 ) {                                recurseGroups( objArray[i].groupItems )                      }                           // Return to previous values                      objArray[i].locked = l;                      objArray[i].hidden = h;            }  
};  



// populate Live file.
for ( i = 0; i < app.documents.length; i++ ) {    var workingDoc = app.documents[i];       var workingDocFile = workingDoc.fullName;            var aiFile = new File(workingDocFile.toString());           workingDoc.saveAs(aiFile);     }

// Text to Outline
function outlineDocText(  ) {              if ( app.documents.length == 0 ) return;        var docRef = app.activeDocument;                recurseLayers( docRef.layers );      
};    
outlineDocText();   



//recurse Layers
  
function recurseLayers( objArray ) {                for ( var i = 0; i < objArray.length; i++ ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var v = objArray[i].visible;                      if ( !v ) objArray[i].visible = true;                          outlineText( objArray[i].textFrames );                          // Recurse the contained layer collection                      if ( objArray[i].layers.length > 0 ) {                                recurseLayers( objArray[i].layers )                      }                          // Recurse the contained group collection                      if ( objArray[i].groupItems.length > 0 ) {                                recurseGroups( objArray[i].groupItems )                      }                           // Return to previous values                      objArray[i].locked = l;                      objArray[i].visible = v;            }  
};    
function recurseGroups( objArray ) {                for ( var i = 0; i < objArray.length; i++ ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var h = objArray[i].hidden;                      if ( h ) objArray[i].hidden = false;                          outlineText( objArray[i].textFrames );                          // Recurse the contained group collection                      if ( objArray[i].groupItems.length > 0 ) {                                recurseGroups( objArray[i].groupItems )                      }                           // Return to previous values                      objArray[i].locked = l;                      objArray[i].hidden = h;            }  
};    



function outlineText( objArray ) {                // Reverse this loop as it brakes the indexing            for ( var i = objArray.length-1; i >= 0; i-- ) {                          // Record previous value with conditional change                      var l = objArray[i].locked;                      if ( l ) objArray[i].locked = false;                          // Record previous value with conditional change                      var h = objArray[i].hidden;                      if ( h ) objArray[i].hidden = false;                          var g = objArray[i].createOutline(  );                          // Return new group to previous Text Frame values                      g.locked = l;                      g.hidden = h;                }    
}; 


// Menu Command of Find Font 
app.executeMenuCommand('Adobe Illustrator Find Font Menu Item'); 

// populate CTC file.

for ( i = 0; i < app.documents.length; i++ ) {    var workingDoc = app.documents[i];       var workingDocFile = workingDoc.fullName;            var aiFile = new File(workingDocFile.toString().replace(".ai","_CTC.ai"));           workingDoc.saveAs(aiFile);     }                
for ( i = 0; i < app.documents.length; i++ ) {    var workingDoc = app.documents[i];       var workingDocFile = workingDoc.fullName;            var aiFile = Folder (File(workingDocFile.toString().replace("_CTC.ai",".ai")));           app.open (aiFile);     }

 //Launch Workflow Dynamic Action
 function createAction1 ( actionString, set ) {                    var fpath = Folder ( "~/Desktop/" )          var f = File ( fpath + set + '.aia' );                    f.open( 'w' );          f.write( actionString );          f.close();          app.loadAction( f );          f.remove();       } 

function runActionScript1(){            var set = 'diadeis';            var action = 'Launch Workflow';                    var actionString = [            
"/version 3",
"/name [ 7",
"    64696164656973",
"]",
"/isOpen 1",
"/actionCount 1",
"/action-1 {",
"    /name [ 15",
"        4c61756e636820576f726b666c6f77",
"    ]",
"    /keyIndex 0",
"    /colorIndex 0",
"    /isOpen 0",
"    /eventCount 1",
"    /event-1 {",
"        /useRulersIn1stQuadrant 0",
"        /internalName (adobe_commandManager)",
"        /localizedName [ 16",
"            416363657373204d656e75204974656d",
"        ]",
"        /isOpen 0",
"        /isOn 1",
"        /hasDialog 0",
"        /parameterCount 3",
"        /parameter-1 {",
"            /key 1769238125",
"            /showInPalette 4294967295",
"            /type (ustring)",
"            /value [ 18",
"                4c61756e636820576f726b666c6f772e2e2e",
"            ]",
"        }",
"        /parameter-2 {",
"            /key 1818455661",
"            /showInPalette 4294967295",
"            /type (ustring)",
"            /value [ 15",
"                4c61756e636820576f726b666c6f77",
"            ]",
"        }",
"        /parameter-3 {",
"            /key 1668114788",
"            /showInPalette 4294967295",
"            /type (integer)",
"            /value 2164260958",
"        }",
"    }",
"}"            ].join( "\n" );            createAction( actionString, set );            app.doScript( action, set );            app.unloadAction( set, "" );        }  

runActionScript1();

alert('Completed');
}
             else              {                               alert('Multiple Artworks are opened.\n Close all other reference files \n Expect Final artwork file');                  !  }

Thanks and regards.

Kalaimani.S

Viewing all 12845 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>