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

Unable to export last asset as PNG out of a selection!

Community Beginner ,
Feb 15, 2018 Feb 15, 2018

Copy link to clipboard

Copied

Hi

I had wrote a script to export my selection as PNG through asset export. But the last selection is not exporting as PNG throwing an error. When it comes to SVG in the same script its working fine. Ill paste the sample script here, please correct me if I had committed some mistake.

I reiterate SVG export working fine in below script its only problem with PNG.

var doc = app.activeDocument;

var selectedObjects = doc.selection;

//remove all assets

if (doc.assets.length>0){

doc.assets.removeAll();

}

//Adding selection to assets panel

for (var i=0; i<selectedObjects.length; i++){

     var currentObject = selectedObjects;

     doc.selection = currentObject;

     var currentAsset = doc.assets.addFromSelection ();

     currentAsset.assetName = currentObject.name;

}

//Collecting new assets

var assets = doc.assets;

//Query Asset ID's

var assetArray = [];

for (var z=0; z<assets.length; z++){

    assetArray=assets.assetID;

    }

//Creation of destination folder

var destFolder = Folder("C:/Users/Xxxxx/Desktop/script/export/Icon_01");

if(!destFolder.exists) destFolder.create();

//Defining assets to export

var whatToExport = new ExportForScreensItemToExport();

whatToExport.assets = assetArray;

whatToExport.artboards ="";

//As SVG

var svgParams = new ExportForScreensOptionsWebOptimizedSVG();

doc.exportForScreens(destFolder, ExportForScreensType.SE_SVG, svgParams, whatToExport);

//As PNG

var pngParams = new ExportForScreensOptionsPNG24();

doc.exportForScreens(destFolder, ExportForScreensType.SE_PNG24, pngParams, whatToExport);

alert('done');

TOPICS
Scripting

Views

787

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
community guidelines
Adobe
Community Expert ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

According to the OMV, the ExportForScreensItemToExport class (the variable whatToExport, in your example above) requires an integer, but you're passing an array.

You may have to loop that array and run the exportForScreens function on each element of the array.

Hope this helps. 😃

Votes

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
community guidelines
Advocate ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

Do you know where i can find info about exportforscreen regarding scripting. Its now 2021 and the docs still dont contain any info about it. It does have info about clouddocs, a new feature, but nothing for exportforscreens?!?

Votes

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
community guidelines
Community Expert ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

no, i'm sorry i don't. the only place i did know of was the OMV in ESTK. But ESTK is dead and you can't even get it on modern operating systems at all. Makes me think i should have cataloged that information when i had it.. doh!

 

Hopefully someone else knows where to find that stuff...

Votes

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
community guidelines
Valorous Hero ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

LATEST

Aha, I did not even know about it until now, but it's been in since 2018 and the types for Adobe reflects the omv from 2015! https://community.adobe.com/t5/illustrator/what-s-new-in-illustrator-scripting-cc2018/td-p/9422236

 

Other than the ESTK OMV, you can try to use the VSCode ESTK-debugger extension and examine the variables panel content to see if it displays any useful information.

Votes

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
community guidelines