Last active
September 20, 2022 10:35
-
-
Save MarshySwamp/0e152c4ab59007f9b1dab33ab284bf61 to your computer and use it in GitHub Desktop.
Select Clipping Mask Base Layer
This file contains 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
selectGroupedBaseLayer(); | |
function selectGroupedBaseLayer() { | |
// Stephen Marsh, v2.0 - 20th September 2022 | |
// Works with a visible or invisible clipping mask base layer | |
for (i = 0; i < activeDocument.layers.length; i++) { | |
if (activeDocument.activeLayer.grouped === true) { | |
//alert("Grouped, move on..."); | |
toggleLayerVisibility(true); | |
selectForwardORBackwardLayer(false, "backwardEnum"); | |
toggleLayerVisibility(true); | |
//activeDocument.activeLayer.visible = true; | |
} | |
// Helper Functions | |
function toggleLayerVisibility(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); | |
} | |
function selectForwardORBackwardLayer(makeVisible, forwardORbackward) { | |
var s2t = function (s) { | |
return app.stringIDToTypeID(s); | |
}; | |
var descriptor = new ActionDescriptor(); | |
var list = new ActionList(); | |
var reference = new ActionReference(); | |
// "forwardEnum" or "backwardEnum" | |
reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t(forwardORbackward)); | |
descriptor.putReference(s2t("null"), reference); | |
// true or false | |
descriptor.putBoolean(s2t("makeVisible"), makeVisible); | |
list.putInteger(15); | |
descriptor.putList(s2t("layerID"), list); | |
executeAction(s2t("select"), descriptor, DialogModes.NO); | |
} | |
} | |
} | |
// or | |
/* | |
selectGroupedBaseLayer(); | |
function selectGroupedBaseLayer() { | |
// Stephen Marsh, v1.0 - 20th September 2022 | |
// Only works with a visible clipping mask base layer | |
if (activeDocument.activeLayer.grouped === true) { | |
//alert("Grouped, move on..."); | |
toggleLayerVisibility(true); | |
selectForwardORBackwardLayer(false, "backwardEnum"); | |
toggleLayerVisibility(true); | |
//activeDocument.activeLayer.visible = true; | |
} | |
// Helper Functions | |
function toggleLayerVisibility(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); | |
} | |
function selectForwardORBackwardLayer(makeVisible, forwardORbackward) { | |
var s2t = function (s) { | |
return app.stringIDToTypeID(s); | |
}; | |
var descriptor = new ActionDescriptor(); | |
var list = new ActionList(); | |
var reference = new ActionReference(); | |
// "forwardEnum" or "backwardEnum" | |
reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t(forwardORbackward)); | |
descriptor.putReference(s2t("null"), reference); | |
// true or false | |
descriptor.putBoolean(s2t("makeVisible"), makeVisible); | |
list.putInteger(15); | |
descriptor.putList(s2t("layerID"), list); | |
executeAction(s2t("select"), descriptor, DialogModes.NO); | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment