0
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.

Adobe ExtendScript で mm単位の新規Illustratorドキュメント作成

Posted at

目的

mm単位のillustratorデータを自動で作成したい。

データの雛形をExtendScriptで自動作成する際、サンプルコードなどで頻出のdocuments.add()をそのまま用いると、pt単位のデータとなる。

  • そのあとの手作業で、mm単位で作業したい
  • 新規ドキュメントダイアログに余計な履歴が残る

新規ドキュメント作成方法の確認

どのような方法があるか、公式リファレンスを見たところ下記方法が確認できた。

Documents methods

公式リファレンス 45ページ

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 の検討

公式リファレンス 44ページ

設定項目が下記のように多く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を引数に加えると、プリントの中身は反映されない

参考

0
1
0

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
0
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?