Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Illustratorのレイヤーに配置されたオブジェクトの数を数えてファイルに書き出すJavaScript Raw
main();
function main() {
var str = layerObjectCount(app.activeDocument);
writeFile(str);
}
function layerObjectCount(docObj) {
var mergeStrings = "";
for (var i = 0, iLen = docObj.layers.length; i < iLen ; i++) {
var currentLayer = docObj.layers[i];
var currentLayerName = currentLayer.name;
var currentLayerObjectLength = currentLayer.pageItems.length;
mergeStrings = mergeStrings + currentLayerName + "\t" + currentLayerObjectLength + "\n";
}
return mergeStrings;
}
function writeFile(str) {
filename = File.saveDialog("書き出すファイル名を入力してください");
if (filename) {
fileObj = new File(filename);
flag = fileObj.open("w");
if (flag) {
fileObj.writeln(str);
}
fileObj.close();
alert("ファイルに書き出しました");
} else {
alert("ファイルが作成できません。アクセス権があるか確認してください");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.