1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

デザイン自動化メモ(InDesignのレイヤーを追加する)

Last updated at Posted at 2018-06-10

#レイヤーを新規追加する
レイヤーを新規追加します。
何度もデバッグできるように、同じ名前のレイヤーがあったら削除するコードと対にコーディングします。

    for (i=0;i<app.activeDocument.layers.length;i++){
        if (app.activeDocument.layers[i].name == "test") {
            app.activeDocument.layers[i].remove()
        }
    }

    layerObj = app.activeDocument.layers.add();
    layerObj.move(LocationOptions.atBeginning);
    layerObj.name="test";

#レイヤーを新規追加する(改善版)
コメントで指摘いただいた方法のメモ。こっちの方がステップ数が少なくなります。

var l = app.activeDocument.layers.itemByName("test");
if (l.isValid){
l.remove();
} else {
app.activeDocument.layers.add({name: "test"}).move(LocationOptions.atBeginning);
}
1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?