Last active
August 31, 2021 22:56
-
-
Save MarshySwamp/31fb17b82a780a0507074593eb725063 to your computer and use it in GitHub Desktop.
Function to toggle active layer visibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toggleActiveLayerVisibility(true); | |
function toggleActiveLayerVisibility(toggleOptionsPalette) { | |
var s2t = function (s) { | |
return app.stringIDToTypeID(s); | |
}; | |
var descriptor = new ActionDescriptor(); | |
var list = new ActionList(); | |
var reference = new ActionReference(); | |
reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum")); | |
list.putReference(reference); | |
descriptor.putList(s2t("null"), list); | |
descriptor.putBoolean(s2t("toggleOptionsPalette"), toggleOptionsPalette); | |
executeAction(s2t("show"), descriptor, DialogModes.NO); | |
} | |
// or | |
/* | |
// Set back layer visibility to true | |
//Select back layer - Fails if back layer is in a group/set which becomes selected | |
var doc = app.activeDocument; | |
doc.activeLayer = doc.layers[doc.layers.length - 1]; | |
//Set active layer to visible, regardless of current visibility | |
doc.activeLayer.visible = true; | |
*/ | |
// or | |
/* | |
activeLayerVisibility("Shw "); // "Shw " | "Hd " | |
function activeLayerVisibility(toggle) { | |
var c2t = function (s) { | |
return app.charIDToTypeID(s); | |
}; | |
var descriptor = new ActionDescriptor(); | |
var list = new ActionList(); | |
var reference = new ActionReference(); | |
reference.putEnumerated(c2t("Lyr "), c2t("Ordn"), c2t("Trgt")); | |
list.putReference(reference); | |
descriptor.putList(c2t("null"), list); | |
executeAction(c2t(toggle), descriptor, DialogModes.NO); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment