Highlighted

Error when save file with script. Adobe illustrator

Community Beginner ,
Jul 30, 2020

Copy link to clipboard

Copied

Wrote script to save file.

When try run script in Os mac all is ok, when try it on Windows write this error ( Could not write the file. an assertion has faild )

Why it happens?

IMG_8503.JPG

TOPICS
Scripting, Tools

Views

97

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Error when save file with script. Adobe illustrator

Community Beginner ,
Jul 30, 2020

Copy link to clipboard

Copied

Wrote script to save file.

When try run script in Os mac all is ok, when try it on Windows write this error ( Could not write the file. an assertion has faild )

Why it happens?

IMG_8503.JPG

TOPICS
Scripting, Tools

Views

98

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 30, 2020 1
Engaged ,
Jul 30, 2020

Copy link to clipboard

Copied

What is the script? It's probably a path resolution or OS specific issue.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2020 1
Community Beginner ,
Jul 30, 2020

Copy link to clipboard

Copied

Script just save file in jpg and eps) nothing difficult

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2020 0
Engaged ,
Jul 30, 2020

Copy link to clipboard

Copied

Impossible to debug something we can't see. Can you post what you have regardless of difficulty? Otherwise you expect us to rewrite everything from scratch instead of just pointing out the issue in your code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2020 1
Community Beginner ,
Jul 30, 2020

Copy link to clipboard

Copied

no problem) take it))

 

function main () {

 var destFile = '/Users/andrey/Desktop';
 var newFile = new File(destFile);
// save eps and ai
 var saveDoc = app.activeDocument;
 var saveEps = new EPSSaveOptions();
 var saveAi = new IllustratorSaveOptions();
 saveEps.cmykPostScript = false;
 saveEps.embedAllFonts = false;
 saveAi.compatibility = Compatibility.ILLUSTRATOR17;
 saveAi.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
 saveDoc.saveAs( newFile, saveEps );
 saveDoc.saveAs( newFile, saveAi);

// save jpg

 var exportOptions3 = new ExportOptionsJPEG();
 var type3 = ExportType.JPEG;
 var fileSpec3 = new File(destFile);
 exportOptions3.antiAliasing = false;
 exportOptions3.qualitySetting = 100;
 app.activeDocument.exportFile( fileSpec3, type3, exportOptions3 );

}

main();

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2020 0
Adobe Community Professional ,
Jul 30, 2020

Copy link to clipboard

Copied

Hi,

Could you please try your script by changing

var destFile = '/Users/andrey/Desktop';

to

var destFile = Folder.desktop;

 

So complete script will be like

function main() {
    var destFile = Folder.desktop;
    var newFile = new File(destFile);
    // save eps and ai
    var saveDoc = app.activeDocument;
    var saveEps = new EPSSaveOptions();
    var saveAi = new IllustratorSaveOptions();
    saveEps.cmykPostScript = false;
    saveEps.embedAllFonts = false;
    saveAi.compatibility = Compatibility.ILLUSTRATOR17;
    saveAi.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
    saveDoc.saveAs(newFile, saveEps);
    saveDoc.saveAs(newFile, saveAi);

    // save jpg

    var exportOptions3 = new ExportOptionsJPEG();
    var type3 = ExportType.JPEG;
    var fileSpec3 = new File(destFile);
    exportOptions3.antiAliasing = false;
    exportOptions3.qualitySetting = 100;
    app.activeDocument.exportFile(fileSpec3, type3, exportOptions3);
}

main();

 

Let us know if this works on Windows machine or not.

 

Best regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 30, 2020 0
Community Beginner ,
Jul 31, 2020

Copy link to clipboard

Copied

Thaths error again(( 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2020 0
Engaged ,
Jul 31, 2020

Copy link to clipboard

Copied

Please excuse the obvious question, but isn't a root directory required in the path in Windows?  So

 

var destFile = "/C/Users/andrey/Desktop";

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2020 0
Adobe Community Professional ,
Jul 31, 2020

Copy link to clipboard

Copied

But I think Folder.desktop will give correct path irrespective of the OS version. 

Best regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2020 0
Adobe Community Professional ,
Jul 31, 2020

Copy link to clipboard

Copied

May be some permission issues with the Desktop path on Windows. Could not write a file is an error related to the permission. So, you can try by chaning permission or path location.

Best regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2020 1
Enthusiast ,
Jul 31, 2020

Copy link to clipboard

Copied

Salut!

Ce script fonctionne sur CS6 Windows 7

avec une de ces deux lignes:

var destFile = '/Users/René/Desktop';
var destFile = '~/Desktop';

Je ne sais pas comment traduire en français le mot Assertion ? (affirmation)

C'est sur le même ordinateur ?

René

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 31, 2020 1