Created
April 23, 2025 05:49
-
-
Save monokano/1389fc737a84f99a77edc5e151cb53d7 to your computer and use it in GitHub Desktop.
テキストオブジェクトのみ「オブジェクトのアウトライン」を適用するIllustrator用スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Illustrator用スクリプト | |
| // 選択されたテキストオブジェクトに「効果 > パス > オブジェクトのアウトライン」を適用します | |
| // テキストオブジェクトではないものが混在していてもOK | |
| // グループが混在していてもOK | |
| if (app.documents.length > 0) { | |
| var doc = app.activeDocument; | |
| var originalSelection = doc.selection; // 現在の選択状態を一時保存 | |
| if (originalSelection.length === 0) { | |
| alert("オブジェクトを選択してください。"); | |
| } else { | |
| var targets = []; | |
| /** | |
| * 指定されたオブジェクトに対して、再帰的にテキストフレームを収集します。 | |
| * ポイント文字(POINTTEXT)およびエリア内文字(AREATEXT)のみが対象です。 | |
| * グループ内のオブジェクトにも対応します。 | |
| */ | |
| function collectTextFrames(item) { | |
| if (item.typename === "TextFrame" && | |
| (item.kind === TextType.POINTTEXT || item.kind === TextType.AREATEXT)) { | |
| targets.push(item); // 処理対象として追加 | |
| } else if (item.typename === "GroupItem") { | |
| // グループ内の各要素を再帰的に確認 | |
| for (var j = 0; j < item.pageItems.length; j++) { | |
| collectTextFrames(item.pageItems[j]); | |
| } | |
| } | |
| } | |
| // 現在の選択に含まれるすべてのオブジェクトについてテキストオブジェクトのみを抽出 | |
| for (var i = 0; i < originalSelection.length; i++) { | |
| collectTextFrames(originalSelection[i]); | |
| } | |
| if (targets.length > 0) { | |
| // 対象のテキストオブジェクトのみを一時的に選択 | |
| app.selection = targets; | |
| // メニュー「効果 > パス > オブジェクトのアウトライン」を実行 | |
| app.executeMenuCommand("Live Outline Object"); | |
| // 元の選択状態を復元 | |
| app.selection = originalSelection; | |
| } else { | |
| alert("処理対象となるポイント文字またはエリア内文字が選択されていません。"); | |
| } | |
| } | |
| } else { | |
| alert("ドキュメントが開かれていません。"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment