【发布时间】:2018-08-27 15:57:05
【问题描述】:
我想在 json 文档中列出图层。在我的代码之后:
#include json2.js
var doc = app.activeDocument;
var allLayers = [];
var allLayers = collectAllLayers(doc, allLayers);
function collectAllLayers (doc, allLayers){
for (var m = 0; m < doc.layers.length; m++){
var theLayer = doc.layers[m];
if (theLayer.typename === "ArtLayer"){
allLayers.push(theLayer);
}else{
collectAllLayers(theLayer, allLayers);
}
}
return allLayers;
}
var json = JSON.stringify(allLayers);
alert(json);
我收到一个错误General Photoshop error occurred.This functionality may not be avaliable in this version of photoshop
我想列出组和层 ex。像这样:
Group1
> Layer 1
> Layer 2
> Group 2
> > Layer 3
> > Layer 4
> > Group 3
> > > Layer 5
> > > Layer 6
> Layer 3
你有什么想法吗? 提前感谢您的回答和帮助!
【问题讨论】:
标签: javascript json photoshop