I found a way to achieve this with only 5 steps.
I wrote 2 scripts: one toggles visibility of all sublayers under selected layer, and the other toggle visibility of the selected layer and its first child.
Now, whenever I need to move a layer with hidden sublayers, it takes me 5 steps, 3 of which are mapped to keyboard shortcuts:
- Make all sublayers visible (F2)
- Select all sublayers by clicking the grey dot
- Move
- Make all sublayers invisible (F2)
- Make selected layer and its first child visible (F3)
Script 1:
// This is a script to toggle visibility of all sublayers under selected layer
var MAX_RECURSION = 10000 // limit recursion size to prevent crashes
var recursionDepth = 0;
var visibility = !activeDocument.activeLayer.visible;
toggleVisible(activeDocument.activeLayer)
if (recursionDepth > MAX_RECURSION) {
alert("Warning: partial success")
}
function toggleVisible(currLayer) {
recursionDepth++;
currLayer.visible = visibility;
if (recursionDepth > MAX_RECURSION) {
return;
}
if (currLayer.layers != null) {
for (var i = 0; i < currLayer.layers.length; i++) {
toggleVisible(currLayer.layers[i]);
}
}
}
Script 2:
// This is a script to toggle visibility for active layer and first child
currLayer = activeDocument.activeLayer
visibility = !currLayer.visible;
currLayer.visible = visibility;
if (currLayer.layers != null && currLayer.layers.length != 0)
currLayer.layers[0].visible = visibility;
enter code here