目的
mm単位のillustratorデータを自動で作成したい。
データの雛形をExtendScriptで自動作成する際、サンプルコードなどで頻出のdocuments.add()
をそのまま用いると、pt単位のデータとなる。
- そのあとの手作業で、mm単位で作業したい
- 新規ドキュメントダイアログに余計な履歴が残る
新規ドキュメント作成方法の確認
どのような方法があるか、公式リファレンスを見たところ下記方法が確認できた。
Documents methods
Method | What it does |
---|---|
add ([documentColorSpace] [, width] [, height] [, numArtBoards] [, artboardLayout] [, artboardSpacing] [, artboardRowsOrCols]) |
Creates a new document using optional parameters and returns a reference to the new document. |
addDocument (startupPreset [, presetSettings] [, showOptionsDialog]) |
Creates a document from the preset, replacing any provided setting values, and returns a reference to the new document. |
addDocumentNoUI (startupPreset) |
Creates a document without showing in UI |
※新規ドキュメント作成サンプルコード
// Creates a new document with an RGB color space
app.documents.add( DocumentColorSpace.RGB );
documents.add の場合
設定するパラメータがない。作成後の変更は不可?未確認。
※document.rulerUnit
は読み取り専用のため後からいじれない。
documents.addDocument の検討
設定項目が下記のように多くunits
で単位も設定できる。
- artboardLayout
- artboardRowsOrCols
- artboardSpacing
- colorMode
- documentBleedLink
- documentBleedOffsetRect
- height
- numArtboards
- previewMode
- rasterResolution
- title
- transparencyGrid
- typename
- units
- width
var doc = app.documents.addDocument("プリント"); // A4 CMYKで良ければプリセットにあるのを指定するのが手っ取り早い
var documentPreset = new DocumentPreset();
documentPreset.units = RulerUnits.Millimeters; // mm単位の設定
var doc = app.documents.addDocument("", documentPreset); // DocumentPresetを第二引数に加えるとmm単位のドキュメントが作成できる
var doc = app.documents.addDocument("プリント", documentPreset); // DocumentPresetを引数に加えると、プリントの中身は反映されない