Sorry I forgot I posted here.
batch-export is better but i still can't record all actions i wish.
Involving Photoshop here is another overkill.
I found the best way to export it with this simple script:
/**
* Remixer: @herkulano (http://www.herkulano.com)
* Thanks to: Niels Bosma ([email protected])
*/
var folder = Folder.selectDialog();
var document = app.activeDocument;
if (document && folder) {
$.writeln(document.width);
saveToRes (16, "ldpi");
saveToRes(32, "mdpi");
saveToRes(64, "hdpi");
saveToRes(128, "xhdpi");
//saveToRes(300, "xxhdpi");
//saveToRes(400, "xxxhdpi");
}
function saveToRes(scaleTo, resFolderName) {
scaleTo = scaleTo/document.width*100.0;
$.writeln(scaleTo);
$.writeln((scaleTo*document.width)/100.0);
//return;
var i, layer,
file, options,
resFolder;
resFolder = new Folder(folder.fsName + "/drawable-" + resFolderName);
if (!resFolder.exists) {
resFolder.create();
}
for (i = document.layers.length - 1; i >= 0; i--) {
layer = document.layers[i];
if (!layer.locked && layer.name.indexOf("!") === -1) {
hideAllLayers();
layer.visible = true;
file = new File(resFolder.fsName+ "/" + layer.name + ".png");
$.writeln(resFolder.fsName);
$.writeln(file.fsName);
$.writeln(layer.name);
options = new ExportOptionsPNG24();
options.antiAliasing = true;
options.transparency = true;
options.artBoardClipping = true;
options.verticalScale = scaleTo;
options.horizontalScale = scaleTo;
document.exportFile(file, ExportType.PNG24, options);
}
}
}
function hideAllLayers() {
var i, layer;
for (i = document.layers.length - 1; i >= 0; i--) {
layer = document.layers[i];
if (!layer.locked && layer.name.indexOf("!") === -1) {
layer.visible = false;
}
}
}
I've found it somewhere and just modified sizes to define them in pixels.
Simply create text file, paste this code, save as .jsx and place the file in illustrator's "scripts" folder.
Then run it throught File>Scripts>...
It will do all the job i mentioned in a single action, setting files names from layers names and place them to appropriate folders. You can exclude certain layers by hiding and locking them.