Skip to main content
Inspiring
May 17, 2023
Answered

Illustrtor script for Enfocus Switch (save .ai or .eps low version)

  • May 17, 2023
  • 1 reply
  • 676 views

The problem is that im using a third party app. (Enfocus Switch) to run illustrator. I need to export low version of ai or eps. Default is the highest. Old cutting plotter only works with low version files. I know that the script is quite simple, but my knowledge of scripting is very weak. I will be grateful if you help. I have a more complex startup script from an application, it is not suitable for.

 

This topic has been closed for replies.
Correct answer михаил23836861t746

thanks, i solved the problem

 

// Save as Ai 8
var dest = $outfolder + "/" + $filename + ".ai";
var originalInteractionLevel = userInteractionLevel;
var saveName = new File ( dest );

userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

saveOpts = new IllustratorSaveOptions();
saveOpts.compatibility = Compatibility.ILLUSTRATOR8;
saveOpts.generateThumbnails = true;
saveOpts.preserveEditability = true;
$doc.saveAs( saveName, saveOpts );
$outfiles = [dest];

1 reply

Inspiring
May 17, 2023
 
var doc = app.activeDocument;
var start = true;
var ver = 8;
var saveOptions = new IllustratorSaveOptions();
switch (ver){
case 3: saveOptions.compatibility = Compatibility.ILLUSTRATOR3;
break;
case 8: saveOptions.compatibility = Compatibility.ILLUSTRATOR8;
break;
case 9: saveOptions.compatibility = Compatibility.ILLUSTRATOR9;
break;
case 10: saveOptions.compatibility = Compatibility.ILLUSTRATOR10;
break;
case 11: saveOptions.compatibility = Compatibility.ILLUSTRATOR11;
break;
case 12: saveOptions.compatibility = Compatibility.ILLUSTRATOR12;
break;
}
saveOptions.overprint = PDFOverprint.PRESERVEPDFOVERPRINT;
if (ver <= 9) {
saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
}
if (ver >= 7) {
saveOptions.embedLinkedFiles = false;
}
if (ver >= 9) {
saveOptions.fontSubsetThreshold = 100;
saveOptions.embedICCProfile = false;
}
if (ver >= 10) {
saveOptions.compressed = true;
saveOptions.pdfCompatible = false;
}
var preffix = "_sb_";
var suffix = "";
var noname = "0";
 
if (documents.length > 0){
if (doc.saved==false) {
alert('File must be saved before execute script!!!','saveLayersToAI',true);
start = false;
}
if (start){
fullDocName = doc.fullName;
for (j=0; j<doc.layers.length; j++){
if ((doc.layers[j].printable == true)&&(doc.layers[j].locked == false)) {
doc.layers[j].locked = true;
nameLayer = doc.layers[j].name;
for (i=0; i<doc.layers.length; i++){
if (doc.layers[i].locked == false){
doc.layers[i].visible = true;
doc.layers[i].remove();
i = i-1;
}
}
for (i=0; i<doc.layers.length; i++){
doc.layers[i].locked = false;
doc.layers[i].visible = true;
}
var param = doc.name.split('.');
realDocName = param[0];
if (nameLayer == noname) docName = preffix+realDocName+suffix;
else docName = preffix+realDocName+'_'+nameLayer+suffix;
var saveName = new File ( doc.path + "/" + docName );
doc.saveAs( saveName, saveOptions );
doc.close(SaveOptions.DONOTSAVECHANGES);
doc = null;
app.open (fullDocName);
doc = app.activeDocument;
}
}
}
}
михаил23836861t746AuthorCorrect answer
Inspiring
May 17, 2023

thanks, i solved the problem

 

// Save as Ai 8
var dest = $outfolder + "/" + $filename + ".ai";
var originalInteractionLevel = userInteractionLevel;
var saveName = new File ( dest );

userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

saveOpts = new IllustratorSaveOptions();
saveOpts.compatibility = Compatibility.ILLUSTRATOR8;
saveOpts.generateThumbnails = true;
saveOpts.preserveEditability = true;
$doc.saveAs( saveName, saveOpts );
$outfiles = [dest];