Skip to content

Instantly share code, notes, and snippets.

@milligramme
Created November 28, 2013 09:53
Show Gist options
  • Select an option

  • Save milligramme/7689600 to your computer and use it in GitHub Desktop.

Select an option

Save milligramme/7689600 to your computer and use it in GitHub Desktop.
// Object Layer Optionsのメモ
var doc = app.documents[0];
var rect = doc.rectangles.add({geometricBounds:[0,0,200,200]});
rect.place(new File("~/Desktop/pasta.ai"));
var g = rect.graphics[0];
$.writeln("最初のid" + g.id);
var gl = g.graphicLayerOptions.graphicLayers;
for (var i=0, len=gl.length; i < len ; i++) {
$.writeln("====");
$.writeln("name:" + gl[i].name);
// 元のレイヤーの状態
$.writeln("originalVisibility:" + gl[i].originalVisibility);
// InDesignで配置されてるときの状態
$.writeln("currentVisibility:" + gl[i].currentVisibility);
};
// オブジェクトレイヤーオプションで表示非表示を切り替えると
// 参照するpdfのオブジェクトidが変わってしまうので
// 1回しか変更できない
gl.item("en").currentVisibility = true;
// もう g は存在しないのでエラーになる
// gl.item("ja").currentVisibility = true
// gl.item("fr").currentVisibility = false
// $.writeln(g.id);
$.writeln("次のid" + rect.graphics[0].id);
rect.graphics[0].graphicLayerOptions.graphicLayers.item("ja").currentVisibility = true;
$.writeln("その次のid" + rect.graphics[0].id);
rect.graphics[0].graphicLayerOptions.graphicLayers.item("fr").currentVisibility = false;
// 最初のid1252
// ====
// name:レイヤー 1
// originalVisibility:true
// currentVisibility:true
// ====
// name:en
// originalVisibility:false
// currentVisibility:false
// ====
// name:fr
// originalVisibility:true
// currentVisibility:true
// ====
// name:ja
// originalVisibility:false
// currentVisibility:false
// 次のid1262
// その次のid1275
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment