LoginSignup
0

More than 5 years have passed since last update.

【AppleScript+Illustrator】オーバープリントアイテムを選択

Posted at

IllustratorのオーバープリントがONになっているアイテムを抽出し、選択した状態にします。

on run
    with timeout of (60 * 60) seconds
        try
            activate
            set start_dialog to display dialog "隠しとロックをすべて解除してから実行します。" with icon note giving up after 60 * 5
            if (gave up of start_dialog) then return

            tell application id "com.adobe.Illustrator"
                set ai_docs to documents
                if (length of ai_docs) is 0 then error "ファイルが開かれていません。"

                tell current document
                    activate

                    (*隠しとロックの解除*)
                    set invisible_layers to (layers whose visible is false)
                    repeat with invisible_layer in invisible_layers
                        set properties of invisible_layer to {visible:true}
                    end repeat
                    set locked_layers to (layers whose locked is true)
                    repeat with locked_layer in locked_layers
                        set properties of locked_layer to {locked:false}
                    end repeat

                    delay 0.1

                    set hide_items to (page items whose hidden is true)
                    repeat with hide_item in hide_items
                        set properties of hide_item to {hidden:false}
                    end repeat
                    set lock_items to (page items whose locked is true)
                    repeat with lock_item in lock_items
                        set properties of lock_item to {locked:false}
                    end repeat

                    delay 0.1

                    (*パスアイテムチェック*)
                    set overprint_items to (path items whose (((fill overprint is true) and (guides is false)) or ((stroke overprint is true) and (guides is false))))

                    (*埋込画像チェック*)
                    set overprint_items to overprint_items & (raster items whose overprint is true)

                    (*テキストフレームチェック*)
                    set text_frames to text frames
                    repeat with text_frame in text_frames
                        set overprint_chars to (characters of text_frame whose ((overprint fill is true) or (overprint stroke is true)))
                        if 0 < (length of overprint_chars) then set overprint_items to overprint_items & {text_frame}
                    end repeat

                    (*対象の選択*)
                    if 0 < (length of overprint_items) then
                        set selection to overprint_items
                    else
                        error "オーバープリントは検出されませんでした。"
                    end if
                end tell
            end tell

            activate
            set finish_dialog to display dialog "処理完了しました。" with icon note buttons {"OK"} default button 1 giving up after 60 * 15
            if (gave up of finish_dialog) then return

        on error err_txt
            activate
            display dialog err_txt with icon caution buttons {"OK"} default button 1 giving up after 60 * 15
            return
        end try
    end timeout
end run

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