« コピ本作る人には朗報? | メイン | 書き捨てスクリプト メモ »

●ShadeのUVをフォトショップの選択範囲に

2009年12月 1日    

書捨て状態だったスクリプトを公開
MacOSXのShadeとPhotoshop環境以外では使いようがないけれど
何かの参考に


import sys
import commands

##ApleScript部分ここから##
AppleScript_="""
on run argv
set argv_ to item 1 of argv
set point_list to {}
tell application "Adobe Photoshop CS3"
--activate
set width_ to width of current document as pixels
set Height_ to height of current document as pixels
if ((count word of argv_) mod 2) = 1 then
return
else
repeat with i from 1 to (count word of argv_) div 2
set a1 to (word (i * 2 - 1) in argv_ as number) * width_
set a2 to (word (i * 2) in argv_ as number) * Height_
set end of point_list to {a1, a2}
end repeat
end if
--選択範囲を追加
select current document region point_list combination type extended
end tell
end run
"""
##AppleScript部分ここまで##

##選択されている面のUVを取得
shd_shape = xshade.scene().active_shape()
f=commands.getoutput('osascript -e \'tell application \"Adobe Photoshop CS3\" to deselect selection of current document\'')
for i in range(shd_shape.number_of_faces):
if (shd_shape.face(i).active):
UV_list = shd_shape.face(i).distance_uv #距離UV
#UV_list = shd_shape.face(i).parameter_uv #パラメータUV値
argv_ = ""
for j in range(len(UV_list)):
(u,v) = UV_list[j]
argv_ = argv_ + str(u) + " " +str(v) + " "
(u,v) = UV_list[0]
argv_ = argv_ + str(u) + " " +str(v)
#print argv_
f=commands.getoutput('osascript -e \'' + AppleScript_ + '\' \''+ argv_ +'\'')
#print f
f=commands.getoutput('osascript -e \'tell application \"Adobe Photoshop CS3\" to activate\'')

投稿者 Yukimi` : 2009年12月 1日 03:16