Exporting a single layer now supports folders.

Fixes issues when using the "Active Layer Only" and "Inpaint Selection" when folders are present in the document.
This commit is contained in:
Yanko Oliveira
2023-05-13 08:54:07 +01:00
parent 14d81ed954
commit 5c2ad5a420

View File

@@ -9,7 +9,21 @@
// below, then its done, and that solves the promise, but we end up with a dangling "done"
// response from the script execution message. But hey, if it works... ^^'
function exportSelectedLayerOnly() {
var allLayers = app.activeDocument.layers;
// Gets all layers recursively, including the ones inside folders.
function getAllArtLayers (document, layerCollection){
for (var i = 0; i < document.layers.length; i++){
var currentLayer = document.layers[i];
if (currentLayer.typename === "ArtLayer"){
layerCollection.push(currentLayer);
} else {
getAllArtLayers(currentLayer, layerCollection);
}
}
return layerCollection;
}
var allLayers = []
allLayers = getAllArtLayers(app.activeDocument, allLayers);
// Make all layers except the currently selected one invisible, and store
// their initial state.
layerStates = []