Copy link to clipboard
Copied
I thought this already existed somewhere but I can't find it back so far...
What I've found was a thread with no replies...
Photoshop: “Hide all layers above this one” (2012) http://feedback.photoshop.com/conversations/photoshop/photoshop-hide-all-layers-above-this-one/5f5f4...
And some code that does not seem to be for PS ...
"Here’s a script that will select all layers above a single selected layer"
www.aenhancers.com/viewtopic.php?t=2143
What I would like is to be able to hide all layers above my current one, like this ...
- I don't often use more than 20 to 40 layers, so it doesn't have to be the fastest.
- I also may not often need that when inside a nested Group, so if that complicates things too much, feel free to leave it out — but preferablt not; I might be overlooking some situations... I'd already be very happy with a basic version though 🙂
TIA!
var d = new ActionDescriptor();
var r = new ActionReference();
var i0 = app.activeDocument.activeLayer.itemIndex;
for (var i = app.activeDocument.layers[0].itemIndex; i > i0; i--)
{
var r1 = new ActionReference();
r1.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerKind"));
r1.putIndex(stringIDToTypeID("layer"), i);
if (executeActionGet(r1).getInteger(stringIDToTypeID("layerKind")) != 7)
r.putIndex(stringIDToTypeID("layer"), i);
}
d.put
...
arr = [], (function(v) {var vp = v.parent; if (vp.typename == 'LayerSet') callee(vp), arr.push(vp.id)})(aL = (aD = activeDocument).activeLayer)
arr.push(aL.id); (function(v) {var i = 0; while(arr.length) {(vi = v[i++]).id == arr[0] ? (arr.shift(), callee(vi.layers)) : vi.visible = false}})(aD.layers)
Copy link to clipboard
Copied
"Here’s a script that will select all layers above a single selected layer"
> That thread mentioned above was just related of course. I had hoped to be able to change it to HIDE (not Select) and what I want.
Copy link to clipboard
Copied
var d = new ActionDescriptor();
var r = new ActionReference();
for (var i = app.activeDocument.layers[0].itemIndex; i > app.activeDocument.activeLayer.itemIndex; i--)
r.putIndex(stringIDToTypeID("layer"), i);
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("hide"), d, DialogModes.NO);
Copy link to clipboard
Copied
TY r-bin! But this code hides my current Group too.
Just need an eyeball on my current group.
Hm, maybe I can solve that myself...
Copy link to clipboard
Copied
var d = new ActionDescriptor();
var r = new ActionReference();
var i0 = app.activeDocument.activeLayer.itemIndex;
for (var i = app.activeDocument.layers[0].itemIndex; i > i0; i--)
{
var r1 = new ActionReference();
r1.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerKind"));
r1.putIndex(stringIDToTypeID("layer"), i);
if (executeActionGet(r1).getInteger(stringIDToTypeID("layerKind")) != 7)
r.putIndex(stringIDToTypeID("layer"), i);
}
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("hide"), d, DialogModes.NO);
Copy link to clipboard
Copied
This one leaves a Group above selected...
3rd time lucky! 😉
Copy link to clipboard
Copied
OTOH, inside it seems deselected, so I guess it's ok then.
THANKS a LOT! 🙂
Copy link to clipboard
Copied
An error occurs for only one group with only one layer inside it, when that layer is selected.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
What you may be thinking of that does exist is the Alt+Click on a layers visibility icon. That toggle all other visible layers visibility off and a second Alt+Click toggles those layers visibility back on
Copy link to clipboard
Copied
Thx. Yes, though of that and maybe using it too.
What I wanna do is to be able to create a true "Merged from below" under my current layer at any point in time. NOT a Stamp Current and Below (I have that script).
Copy link to clipboard
Copied
arr = [], (function(v) {var vp = v.parent; if (vp.typename == 'LayerSet') callee(vp), arr.push(vp.id)})(aL = (aD = activeDocument).activeLayer)
arr.push(aL.id); (function(v) {var i = 0; while(arr.length) {(vi = v[i++]).id == arr[0] ? (arr.shift(), callee(vi.layers)) : vi.visible = false}})(aD.layers)
Copy link to clipboard
Copied
When it looks like Chinese, I know it's gonna work! 😉
Yeah, I prefer that the eye goes out from the folders above. It's more intuitive.
Great!! Thank You, Kukurykus 🙂
Copy link to clipboard
Copied
Yes it looks so. Forum developers still did not adapt codings to be not wrapped to next line. Horizontal Scrollable Bar would be so intuitive here, but let us waits ome years - Adobe can surprise sometimes, like doing obvious things when you are enough tired of waiting for them to say, what now? Now after I learned to live with it and forgot I ever needed it 😛
That's the difference. r-bin script turning off layers in folders, mine only folders, still the mine difference is he used Action Manager that his code works much faster, especially for bottom layers. It's because it starts counting from bottom, while Document Object Model from top. Yeah that means sometimes DOM beats AM, or at least is even.
Btw you should mark his and mine solutions as correct answers 😉
Copy link to clipboard
Copied
Such a result. This is normal?
Copy link to clipboard
Copied
If you understand his intention then yes 😉 He probably wants to see only active layer and the stuff that is below it. Of course your script does the same, I mean the other way (hiding layers in layerSets), but at the end it shows the same content of document window .
Copy link to clipboard
Copied
In my mind a Merged Visible form Below makes sense in many situations.
I like to do "stupid things" and then save myself 😜
A fictional example...
Let's say I add an adjustment layer that makes the face green (which I want), but I don't like how it also affects some other parts in the picture. My fictional plugin that makes perfect face masks now doesn't work cos the face is green and it looks for skin tones... With a Merged Visible from Below I can automate that mask from below.
If I knew in advance what I was gonna do, I could of course first make the mask, then go wild with colors.
But there are many situations for me where this makes sense, or where you can save yourself out of something after the fact. Having such action with this script, I don't have to think — it "just works" at any time (I think).
Copy link to clipboard
Copied
BTW, I don't wanna see the active layer (as the face is green on it 😉 )
I already had such Stamp Current & Below script. I specifically want below only.
(Of course, I can not use this at literally any time, cos I may have made important changes in layers above. But I can use it when I can, or when I'm quick to realize the need...)
Copy link to clipboard
Copied
BTW, the action is of course more elaborated than just this script.
R-bin... Seeing that yours is faster...; if you can make yours look like the result from Kukurykus, you can still win it! 😜
Copy link to clipboard
Copied
Last SPAM...
To be clear, when I use this script, I'm already on a layer I created BELOW my current, so that "current" will become hidden.
Copy link to clipboard
Copied
It is not clear why you need all this? How are you going to turn the layers back on, especially since some of them may have been turned off initially and should remain so.
Copy link to clipboard
Copied
Hm, I feel the fictional example is good. Like I said, there's a whole action that goes with it and that needs to work for several cases.
I turn layers back on by first saving them in a Layer Comp.
What I will usually do is ...
- Make an empty layer UNDER my current and select it
- Use this script to turn off all the above
- Merge Visible in that layer
- Put a mask that I need on that
- Make everything visible again
- Move mask to current layer (or Apply Image normally)
- Delete temp layers
I don't always need the Merge Visible, but IIRC it can act as a dummy layer to catch different situations w/o needing a script.
Copy link to clipboard
Copied
AFAIK, it makes more sense for a Vibrancy Mask too (some wrongly call it a Saturation mask).
Say my current layer has a red that is 80% saturated. I then add an adjustment layer with very strong saturation boost. If I take the mask of this adj. layer, it may not let throught the 20% headroom anymore for that red, as it is maxed out on this adjustment layer (might have 100% coverage), so I want the mask from below.
Again, I don't need this trick if I make the mask first, then adjust. It's for when you do stuff the wrong way around without thinking 😜