Ok, i fix it :
This script export only visible layer
function exportPNG(){
var documents = app.activeDocument;
var docName = app.activeDocument.name;
var docNameNoExt = app.activeDocument.name.split('.')[0];
var docPath = app.activeDocument.path.fsName;
var pngSrvOutput = new Folder("\\\\server_network\\production\\")
if (!pngSrvOutput.exists){
pngSrvOutput.create()
}
var isVisible = new Array();
//Show each layer each time and save a snapshot
for (var i = 0; i < documents.layers.length; i++) {
isVisible[i] = documents.layers[i].visible == true;
}
for (var i = 0; i < documents.layers.length; i++){
//Hide all the layers
for (var j = 0; j < documents.layers.length; j++) {
documents.layers[j].visible = false;
}
// show layer
if (isVisible[i]){
var layerIndex = i;
documents.layers[layerIndex].visible = true;
var layerName = documents.layers[layerIndex].name; // save
var file = new File(pngSrvOutput + "\\" + docNameNoExt + "_" + layerName + "-1.png");
var saveOptions = new PNGSaveOptions();
documents.saveAs(file, saveOptions, true, Extension.LOWERCASE);
}
}
for (var i = 0; i < documents.layers.length; i++){
documents.layers[i].visible = isVisible[i]
}
}
exportPNG()