![見出し画像](https://assets.st-note.com/production/uploads/images/36193467/rectangle_large_type_2_1a7ad07ec48aea3bacd8e4990c8a6e9a.png?width=1200)
スクリプト開発のための参考サイト2 #スクリプト #Illustrator
※ この記事は、全文を公開している「投げ銭スタイル」です。
http://gorolib.blog.jp/archives/70507161.html
からの継続です。note の方が見やすいことがわかり、今後はこちらを更新します。
■■ 参考サイト
■ Illustrator のExtendScript のサイト
Illustrator Scripting | Adobe Developer Connection
https://www.adobe.com/devnet/illustrator/scripting.html
■ Illustrator JavaScript(PDF)
https://www.adobe.com/content/dam/acom/en/devnet/illustrator/pdf/Illustrator_JavaScript_Scripting_Reference_2017.pdf
■ "Scripting Access to XMP Metadata"のことなど(PDF)
https://www.adobe.com/content/dam/acom/en/devnet/scripting/pdfs/javascript_tools_guide.pdf
■ openDialog()とか、fsNameなどの使い方
Adobe CC バージョンJavaScript ファレンス
http://www.openspc2.org/reibun/AdobeJS/CC/index.html
■ JavaScriptの基本文法など
Adobe Illustrator CC自動化作戦
http://www.openspc2.org/book/IllustratorCC/
■ メニューコマンド
【Illustrator】メニューコマンドリスト - Qiita
https://qiita.com/comsk/items/06391cbf2eb25da46771
・すべてを選択…"selectall"
・すべてのアートボードを全体表示…"fitall"
・作業アートボードのすべてを選択…"selectallinartboard"
■ 顔文字みたいな文字列検索(20210220)
→「正規表現」です。このキーワードそのものを忘れてしまうと検索すらできません(笑)。
■■ 参考フレーズ(コピペ用)
■ 自分のフルパス
activeDocument.fullName.fsName
■ 自分のフルパスのファイル名以外の部分
activeDocument.fullName.fsName.split("/").reverse().slice(1).reverse().join("/")
■ 今見えているウィンドウの大きさ
activeDocument.views[0].bounds
■ オブジェクトタイプ別記述
activeDocument.pageItems
activeDocument.pathItems
activeDocument.textFrames
activeDocument.groupItems
■ 自分のファイル名
*拡張子あり
activeDocument.fullName.fsName.split("/").reverse()[0]
*拡張子なし
activeDocument.fullName.fsName.split("/").reverse()[0].split(".")[0]
■ Adobe PDF プリセット 一覧
PDFPresetsList
■ 1文字だけの配列
a1= "日月火水木金土"
d1= new Date()
yobi= a1.charAt(d1.getDay())
alert(yobi + "曜日")
■ move文の書き方
n1.move(lay,ElementPlacement.PLACEATEND)
layはレイヤーのことだが、グループでもドキュメントでも使える。
・PLACEATBEGINNING…最前面
・PLACEATEND…最背面
だいたい使うのはこの2種類。
レイヤー作成して階層指定するなら、activeDocument 内の順を指定する。
lay.move(activeDocument,ElementPlacement.PLACEATEND)
■ 文字揃え
paragraphs(段落)単位でしかできない。
txt.paragraphs[0].paragraphAttributes.justification = Justification.CENTER(中央揃え)
Justification.RIGHT(右揃え)
Justification.LEFT(左揃え)
■ 簡易的な文字入力ダイアログ
prompt を使って、入力値を受ける。dsp に入力文字が入ります。
function dofn(){
dsp = prompt("文字を入力してください","")
if(!dsp) return // キャンセルで戻る
// dsp を使って続ける
}
![画像1](https://assets.st-note.com/production/uploads/images/36195515/picture_pc_63ab6ff69e2dbfb5932da4c17d962d59.png)
■ OK/キャンセルのシンプルなダイアログ
function dofn(){
if(!confirm('ここに質問文')) return // キャンセルで戻る
// OKなら続ける
}
![画像2](https://assets.st-note.com/production/uploads/images/36195524/picture_pc_844807808f97e0e73c8d0f1358fdf717.png)
■ 中央を返す関数
「array of 4 numbers」を引数として、水平や垂直の中央を返す関数。オブジェクト移動に使うと便利。
function hfnx(hx){return (hx[0]+hx[2])/2}
function hfny(hy){return (hy[1]+hy[3])/2}
例)b2の中心からb1の中心にsxを移動する。
sx.translate(hfnx(b1)-hfnx(b2), hfny(b1)-hfny(b2)
■ 文字サイズ(n1はテキストオブジェクト)
n1.textRange.characterAttributes.size
■ 選択オブジェクト
sel = activeDocument.selection
以上です。不定期で更新します。
※ 以降に文章はありません。もし、この記事がお役に立ちましたら「投げ銭」にてご支援いただければ幸いです。
ここから先は
¥ 100
もし、この情報がお役に立ちましたら、サポートをお願いします。いただいたお金は大切に使います!