#target illustrator
var mm=2.834645669;
var startpath= File($.fileName).parent;
var haserror=false;
var errfolder="";
function toSystemPath(path)
{
if ((path instanceof File) || (path instanceof Folder)) fl=path;
else
fl=new File(path);
return fl.fsName;//path.toString().slice(1,2)+":"+path.toString().slice(2);
}
function MyUnity(){
String.prototype.hexEncode = function(){
//http://stackoverflow.com/questions/21647928/javascript-unicode-string-to-hex
var hex = '';
for(var i=0;i<this.length;i++) {
hex += ''+this.charCodeAt(i).toString(16);
}
return hex;
};
function writeFile(fileDestStr, contents){
var newFile = File(fileDestStr);
newFile.open('w');
newFile.write(contents);
newFile.close();
};
var actionStr = [
"/version 3",
"/name [ 5",
" 5365742032",
"]",
"/isOpen 1",
"/actionCount 1",
"/action-1 {",
" /name [ 8",
" 416374696f6e2031",
" ]",
" /keyIndex 0",
" /colorIndex 0",
" /isOpen 1",
" /eventCount 1",
" /event-1 {",
" /useRulersIn1stQuadrant 0",
" /internalName (ai_plugin_pathfinder)",
" /localizedName [ 10",
" 5061746866696e646572",
" ]",
" /isOpen 0",
" /isOn 1",
" /hasDialog 0",
" /parameterCount 1",
" /parameter-1 {",
" /key 1851878757",
" /showInPalette -1",
" /type (enumerated)",
" /name [ 3",
" 416464",
" ]",
" /value 0",
" }",
" }",
"}"
].join("\n");
// actionStr=actionStr.replace(" /value 8.5039367676"," /value "+Gap);
var actionFileDestStr = Folder.desktop + "/MyAction.aia";
writeFile(actionFileDestStr, actionStr);
var actionFile = File(actionFileDestStr);
app.loadAction(actionFile);
app.doScript("Action 1", "Set 2");
//clean up
actionFile.remove();
app.unloadAction("Set 2", '');
}
executeMenuCommand("deselectall");
redraw();
while (activeDocument.groupItems.length>0)
{
activeDocument.groupItems[0].selected=true;
MyUnity();
redraw();
executeMenuCommand("deselectall");
redraw();
}