Skip to main content
yshkrish
Participating Frequently
April 15, 2016
Question

Script to make multiple selected layers in to one layer and export

  • April 15, 2016
  • 1 reply
  • 1014 views

Hi ,

Is there any script which could make selected particular layers into single png of one artboard.

suppose i created a list box name mylist1

var docRef = app.activeDocument;

for (var i = 0; i < docRef.layers.length; i++)

{

myList1.add ("item", docRef.layers.name);

}

I want to form mylList1.selected multiple items to one png file using

var exportOptions = new ExportOptionsPNG24();

var type = ExportType.PNG24;

var fileSpec = new File("c:/");

exportOptions.antiAliasing = false;

exportOptions.transparency = false;

exportOptions.saveAsHTML = true;

app.activeDocument.exportFile( fileSpec, type, exportOptions );

I could write code for multiple pngs and other formats.but single png (or other formats) for selected layers is difficult for me.

Please anyone help me writing the code.

Thank you.

This topic has been closed for replies.

1 reply

Disposition_Dev
Legend
April 18, 2016

Can you give us a little more information to work with? Perhaps some screenshots of the layers panel. Do you want to cycle through the layers programmatically or do you just want to be able to click on a few layers and export the artwork on those layers?

I think i have a solution for you, but i want to be sure i know what you're asking for before i spend the time writing the code.

yshkrish
yshkrishAuthor
Participating Frequently
April 19, 2016

I just want to be able to click on a few layers of selected artboard and export the artwork of those layers to png,jpeg,tiff .

Thank you.

Disposition_Dev
Legend
April 19, 2016

Ok. To my knowledge there isn't a way to determine multiple selected layers. "Selected" isn't a property that we can access. You can refer to the app.activeDocument.activeLayer, but that doesn't let you choose multiple layers and export.

So here's my suggestion. We DO  have acccess to the locked and visible properties, so I would start there. Now, i don't know how many layers are in your file and what percentage of those layers you want to export, which is why i was asking for a screenshot, but i'll try to wade through this as best i can.

Let's say you have 10 layers in your document, and you want to export 3 of them. You could lock the 3 layers you want to export and then run a script that hides all unlocked layers and then runs your export function.

Vise versa, if you have 10 layers and you want to export 7 of them, you could simply lock the layers you don't want, and run a script that hides the locked layers and runs your export function.

Lastly and easiest solution, is to check out the MultiExporter.jsx written by Matthew Ericson. This gives you most, if not all the functionality you're looking for. The only thing I don't like about this script is the requirement that you name your artboard. But it's not that big a deal. You may have to fiddle with this one to really make it do what you're looking for, but it's a great place to start.

Export Illustrator Layers and/or Artboards as PNGs and PDFs | Matthew Ericson - ericson.net