AI テキストをだいたい順番に取得

_UNI3748

IDのテキスト書き出しと同じく選択テキストをだいたい順番通りに取得してクリップボードにコピーします。

スクリプトエディタで開く

tell document 1 of application “Adobe Illustrator”
set c3 to 0
set {a1, a2, a3} to {contents of text frames whose selected is true, “”, position of text frames whose selected is true}
repeat with a4 from 1 to count a1
set {c1, c2} to {a3‘s item a4‘s item 1, a3‘s item a4‘s item 2}
tell current application
if c1 < 0 then
set c1 toc1
set c3 to 1
end if
if c2 < 0 then
set c2 toc2
set c3 to 1
end if
set c1 to ((“0000” & ((c1 div 1) as Unicode text)) as Unicode text)’s characters -4 thru end & (c1 mod 1 as Unicode text)’s characters 2 thru end as Unicode text
set c2 to ((“0000” & ((c2 div 1) as Unicode text)) as Unicode text)’s characters -4 thru end & (c2 mod 1 as Unicode text)’s characters 2 thru end as Unicode text
set a2 to a2 & c2 & “:” & c1 & “:” & a4 & “\n”
end tell
end repeat
end tell
tell current application
if c3 = 1 then set a5 to do shell script “echo “ & quoted form of a2 & ” | sort -it:  | sed -e ‘s/.*://’ | perl -pe ‘s/^$\n//'” –r逆順
if c3 = 0 then set a5 to do shell script “echo “ & quoted form of a2 & ” | sort -irt:  | sed -e ‘s/.*://’ | perl -pe ‘s/^$\n//'” –r逆順
end tell
set a6 to “”
set a5 to paragraphs of a5
repeat with a7 in a5
set a6 to a6 & a1‘s item a7 & “\r\r”
end repeat
set the clipboard to a6