Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
1

Error when save file with script. Adobe illustrator

Community Beginner ,
Jul 30, 2020 Jul 30, 2020

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.JPGexpand image

TOPICS
Scripting , Tools
664
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Enthusiast ,
Jul 30, 2020 Jul 30, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2020 Jul 30, 2020

Script just save file in jpg and eps) nothing difficult

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 30, 2020 Jul 30, 2020

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2020 Jul 30, 2020

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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2020 Jul 30, 2020

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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 31, 2020 Jul 31, 2020

Thaths error again(( 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 31, 2020 Jul 31, 2020

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

 

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

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2020 Jul 31, 2020

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

Best regards
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 31, 2020 Jul 31, 2020

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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 31, 2020 Jul 31, 2020
LATEST

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é

 

 

 

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