【DTP作業効率化】スプレッドシートから緯度経度を取得してIllustrator上に展開する--(3)Illustratorの操作
前の記事
上画像のように、スプレッドシートで緯度経度を取得して、Illustrator上に展開させる過程のIllustrator部分について。
手順
マークのベースを起点に配置して、選択。
Applescriptを実行し、スプレッドシート P1の値を入力。「展開」という名前のレイヤーが作られ、内容が展開される。
詳細
●マークのベースを起点に配置して、選択。
展開させたいマークのベースを起点になる場所に配置して、選択する。スプレッドシートの2行目(黄色の行)が起点になる。
マークはグループ化しておく。テキストフレームが含まれていれば、スプレッドシート A列の施設名が入力される。
●Applescriptを実行し、スプレッドシート P1の値を入力。
スクリプトを実行すると下図のような窓がでるのでスプレッドシートP1の値を入力。
下図のようなマークでも可能。
●Applescriptとアプリケーションファイル
下記のコードを「スクリプトエディタ」にコピペまたは、アプリケーションダウンロード、ダブルクリックで使えます。
global the_text_frame
tell application "Adobe Illustrator"
activate
display dialog "素を入力してください" default answer "" buttons {"キャンセル", "OK"}
end tell
set the_text to text returned of result
set array1 to divide_text(the_text, "/")
set array2 to {}
repeat with an_item in array1
set temp_array to divide_text(an_item, ",")
set the end of array2 to temp_array
end repeat
tell application "Adobe Illustrator"
tell current document
set spread_layer to make a new layer with properties {name:"展開"}
set the_objects to selection
set the_text_frame to ""
repeat with an_item in the_objects
set its_class to class of an_item
if its_class is text frame then
set the_text_frame to an_item
else if its_class is group item then
my into_the_group(an_item)
end if
end repeat
set y to item 1 of position of item 1 of the_objects
set x to item 2 of position of item 1 of the_objects
repeat with i in array2
set x_gap to item 1 of i
set y_gap to item 2 of i
set new_x to x + x_gap
set new_y to y + y_gap
set new_one to duplicate the_objects with properties {position:{new_y, new_x}}
if the_text_frame is not "" then
set contents of the_text_frame to item 3 of i
end if
move new_one to beginning of spread_layer
end repeat
end tell
end tell
to into_the_group(group_item)
tell application "Adobe Illustrator"
tell current document
set its_items to page items of group_item
repeat with an_item in its_items
set its_class to class of an_item
if its_class is text frame then
set the_text_frame to an_item
else if its_class is group item then
my into_the_group(an_item)
end if
end repeat
end tell
end tell
end into_the_group
to divide_text(the_text, the_delimiter)
tell application "Finder"
set the_original_delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to the_delimiter
set these_items to text items of the_text
set AppleScript's text item delimiters to the_original_delimiters
return these_items
end tell
end divide_text
以上です。
この記事が気に入ったらサポートをしてみませんか?