Skip to content

Instantly share code, notes, and snippets.

@sacrifs
Created June 15, 2012 08:53
Show Gist options
  • Save sacrifs/2935495 to your computer and use it in GitHub Desktop.
Save sacrifs/2935495 to your computer and use it in GitHub Desktop.
レイヤーセット(フォルダ)を消すJSX
/**
* レイヤーセット(フォルダ)を消すJSX
*/
var _layers = [];
var _layerSets = [];
main();
function main(){
var document = activeDocument;
var layers = document.layers;
getLayer(layers);
var num = _layers.length;
var j = 0;
for(var i = 0; i < num; i++){
var layer = _layers[i];
layer.moveAfter(document.layers[j++]);
}
num = _layerSets.length;
for(j = 0; j < num; j++){
_layerSets[j].remove();
}
}
function getLayer(layers){
var num = layers.length;
for(var i = 0; i < num; i++){
var layer = layers[i];
if(layer.typename == "LayerSet"){
getLayer(layer.layers);
_layerSets.push(layer);
}
else{
_layers.push(layer);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment