Shade 3D 用pythonの元となる基本モジュール。
xshade |
beep | ビープ音を再生する |
begin_timing | 時間測定を開始する |
begin_timing_figure_window | 図形ウインドウ更新の時間測定を開始する |
create_dialog | ダイアログオブジェクトを作成する |
create_dialog_with_uuid | 指定したuuidでダイアログオブジェクトを作成する |
create_image | 指定されたサイズと色深度のイメージを作成する |
create_image_from_file | 指定されたファイルから読み込んだイメージを作成する |
create_joined_image | 複数のイメージを横に結合して新しいイメージを作成する |
empty_image | 空のイメージオブジェクトを作成する |
end_timing | 時間測定を終了する |
end_timing_figure_window | 図形ウインドウ更新の時間測定を終了し、ウインドウの更新にかかった時間を返す |
euler_from_quaternion | クォータニオンをオイラー角に変換する |
get_amat | 方向ベクトルAを方向ベクトルBに一致させる変換マトリクスを返す |
get_current_time | Shade 3D が起動してからの時間 | get_shadeexplorer_data_path | ShadeExplorerの参照するパスを返す |
get_zmat | 指定した方向ベクトルをZ軸に一致させる変換マトリクスを返す |
idle | 指定時間 Shade 3D をアイドル状態にする |
is_appstore_version | AppStoreビルドかどうか |
load_color_list_1 | カラーリスト1にカラーリスト設定ファイルを読み込む |
load_color_list_2 | カラーリスト2にカラーリスト設定ファイルを読み込む |
load_shortcut | ショートカット設定ファイルを読み込む |
make_plane_equation | 平面を定義する方程式のパラメータを返す。 |
make_tv | グローバル座標系から視野座標系に変換するマトリクスを返す |
message | メッセージウインドウに文字列を出力する |
new_scene | 新規書類を開く |
open_scene | Shade 3D ファイルを開く |
page_setup | 印刷設定ダイアログを表示する |
play_sound | サウンドファイルを再生する |
quaternion_from_euler | オイラー角をクォータニオンに変換する |
quit | Shade 3D を終了する |
reset_timing | 時間測定をリセットする |
save_color_list_1 | カラーリスト1を保存する |
save_color_list_2 | カラーリスト2を保存する |
save_shortcut | ショートカット設定を保存する |
show_message_box | メッセージボックスを表示する |
show_yesnocancel_message_box | 「はい」「いいえ」「キャンセル」ボタン付のダイアログを表示する |
sleep | 指定した時間 Shade 3D をスリープ状態にする |
stop_sound | 再生中のサウンドを停止する |
uniscale_rectangle | 外接する矩形の内側に接し、縦横比の基準となる矩形と(ほぼ)同じ縦横比を持つ矩形を返す |
unmatrix | 変換マトリクスから拡大縮小、せん断、回転、直線移動を抽出する |
beep
ビープ音を再生する。
xshade.beep()
begin_timing_figure_window
図形ウインドウ更新の時間測定を開始する。
end_timing_figure_windowとセットで使用する。
begin_timing、end_timingで囲って使用する。
#moveで形状が図面を10回移動する時間を測定する
xshade.begin_timing()
xshade.begin_timing_figure_window()
for i in xrange(10):
xshade.scene().move_object(None, None, None, [1.0, 0.0, 0.0])
print xshade.end_timing_figure_window()
xshade.end_timing()
create_dialog
ダイアログオブジェクトを作成する。
戻り値 :
dialogオブジェクト
引数 :
int : 数値 : 指定すると値が保持される : 省略可能 : 省略時は値を保持しない
任意の数値を指定することで値が保持されるが、他のスクリプトと値が衝突する可能性がある。
引数には、過去にShade onlineプラグイン/スクリプト開発者サポートページから発行されたIDの指定も可能で、この場合は値の衝突はおこらない。
過去互換用
値を保持する場合は、create_dialog_with_uuidの使用を推奨。
dlg = xshade.create_dialog()
create_dialog_with_uuid
指定したuuidでダイアログオブジェクトを作成する。
戻り値 :
dialogオブジェクト
引数 :
uuid : 128ビットの数値 : 指定すると値を保持する : 省略可能 : 省略時は値を保持しない
参照 :
uuid
#uuidに583DA72C-F329-469E-BEDE-A0349DEAC74Bを指定してダイアログを作成する
dlg = xshade.create_dialog_with_uuid('583DA72C-F329-469E-BEDE-A0349DEAC74B')
create_image
指定されたサイズと色深度のイメージを作成する。
戻り値 :
imageオブジェクト
引数 :
size : イメージのサイズ
引数 :
int : ピクセルの色深度 : 省略可能
設定可能な色深度 :
8(byte/グレイスケール)、16(half/グレイスケール)、32(byte/RGBA)、64(half/RGBA)、128(float/RGBA)
参照 :
image
64、128の場合にはリアルカラー情報付きのイメージを作成する。
64、128は黒で塗りつぶされたイメージが作成され、それ以外ではストライプなどのノイズが入ったイメージが作成される。
#サイズ100,200色深度64でイメージを作成してウインドウで表示する
img = xshade.create_image((100, 200), 64)
img.create_window('sample')
create_image_from_file
指定されたファイルから読み込んだイメージを作成する。
戻り値 :
imageオブジェクト
引数 :
file_path : 拡張子(*.jpgなど) : Noneでファイルダイアログを開く。
参照 :
image
#ファイルからイメージを作成してウインドウで表示する
img = xshade.create_image_from_file(None)
img.create_window('sample')
create_joined_image
複数のイメージを横に結合して新しいイメージを作成する。
戻り値 :
imageオブジェクト
引数 :
imagesオブジェクト
結合する画像のリスト
参照 :
image
#image_aとimage_bを結合してイメージを作成してウインドウで表示する
image_a = xshade.create_image_from_file(None)
image_b = xshade.create_image_from_file(None)
img = xshade.create_joined_image([image_a,image_b])
img.create_window('sample')
end_timing_figure_window
図形ウインドウ更新の時間測定を終了し、ウインドウの更新にかかった時間を返す。
begin_timing_figure_windowとセットで使用する。
戻り値 :
ウインドウの更新にかかった時間
内部的にbegin_timing_figure_window()呼び出し後、複数回実行された figure_windowのpaint(スクリプトでは無効)にかかった時間の平均値を返している。
print xshade.end_timing_figure_window()
euler_from_quaternion
クォータニオンをオイラー角に変換する。
戻り値 :
float3
引数 :
quaternion
クォータニオンとオイラー角は一意に変換できないため、quaternion_from_euler()で逆変換をした場合に同じ値にはならない。
#(1.0, 0.0, 0.0, 0.0)をオイラー角に変換する
print xshade.euler_from_quaternion((1.0, 0.0, 0.0, 0.0))
get_amat
方向ベクトルAを方向ベクトルBに一致させる変換マトリクスを返す。
戻り値 :
mat4
引数 :
vec3 : 方向ベクトルA
引数 :
vec3 : 方向ベクトルB
#(1.0, 0.0, 0.0)を(0.0, 1.0, 0.0)に一致させる変換マトリクスを出力する
print xshade.get_amat((1.0, 0.0, 0.0),(0.0, 1.0, 0.0))
get_current_time
Shade 3D が起動してからの時間。
戻り値 :
int:ms
#Shade 3D が起動してからの時間を出力する
print xshade.get_current_time()
get_shadeexplorer_data_path
ShadeExplorerの参照するパスを返す。
戻り値 :
string
print xshade.get_shadeexplorer_data_path()
get_zmat
指定した方向ベクトルをZ軸に一致させる変換マトリクスを返す。
戻り値 :
mat4
引数 :
vec3 : Z軸に一致させる方向ベクトル
#(1.0, 0.0, 0.0)をZ軸に一致させる変換マトリクスを出力する
print xshade.get_zmat((1.0, 0.0, 0.0))
idle
指定時間 Shade 3D をアイドル状態にする。
引数 :
ms : 1秒は1000ms
#3秒後に「Shade 3D」を出力する
xshade.idle(1800)
print 'Shade 3D'
is_appstore_version
AppStoreビルドかどうか。
戻り値 :
bool
#AppStore版の Shade 3D の場合は1が表示される
print xshade.is_appstore_version()
load_color_list_1
カラーリスト1にカラーリスト設定ファイルを読み込む。
引数 :
file_path
参照 :
save_color_list_1
#設定ファイルをカラーリスト1に読み込む
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(True, '*.shdclt|shdclt')
xshade.load_color_list_1(file_path)
load_color_list_2
カラーリスト2にカラーリスト設定ファイルを読み込む。
引数 :
file_path
参照 :
save_color_list_2
#設定ファイルをカラーリスト2に読み込む
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(True, '*.shdclt|shdclt')
xshade.load_color_list_2(file_path)
load_shortcut
ショートカット設定ファイルを読み込む。
引数 :
file_path
参照 :
save_shortcut
#設定ファイルをショートカットに読み込む
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(True, '*.shdshc|shdshc')
xshade.load_shortcut(file_path)
make_plane_equation
平面を定義する方程式のパラメータを返す。
戻り値 :
float4
引数 :
vec3 : 3個のタプル/リスト
#((100.0, 0.0, 0.0), (200.0, 0.0, 0.0), (150.0, 100.0, 0.0))のパラメータを出力する
print xshade.make_plane_equation(((100.0, 0.0, 0.0), (200.0, 0.0, 0.0), (150.0, 100.0, 0.0)))
make_tv
グローバル座標系から視野座標系に変換するマトリクスを返す。
戻り値 :
mat4
引数 :
f : vec3 : 視点
引数 :
a : vec3 : 注視点
引数 :
bank : float : 傾き
引数 :
shift : bool : あおり補正
引数 :
h_shift : float : シフト
引数 :
v_shift : float : ライズ
引数 :
parallel : int : モード
引数 :
top_view : bool : 平行投影
レガシーなメソッドであるため現在はscene().world_to_view_matrix()の使用を推奨。
#現在のカメラよりマトリクスを出力する camera = xshade.scene().camera f = camera.eye a = camera.target bank = camera.bank shift = False #boolなので現在のcorrectionは使えない h_shift = camera.shift v_shift = camera.rise parallel = camera.camera_mode top_view = camera.distant_camera for i in (f,a,bank,shift,h_shift,v_shift,parallel,top_view): print i print xshade.make_tv(f,a,bank,shift,h_shift,v_shift,parallel,top_view)
message
メッセージウインドウに文字列を出力する。
引数 :
string
#「sample」をメッセージウインドウに出力する
xshade.message('sample')
new_scene
新規書類を開く。
xshade.new_scene()
open_scene
Shade 3D ファイルを開く。
戻り値 :
string
引数 :
file_path : 拡張子(*.shd) : Noneでファイルダイアログを開く。
参照 :
scene.save()
#ファイルを選択して開く
xshade.open_scene(None)
page_setup
印刷設定ダイアログを表示する。
xshade.page_setup()
play_sound
サウンドファイルを再生する。
戻り値 :
bool
引数 :
file_path
引数 :
int : 繰り返し回数(現在無効)
参照 :
stop_sound
#サウンドファイルを選択して再生する
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(True, '*.wav|wav')
xshade.play_sound(file_path)
quaternion_from_euler
オイラー角をクォータニオンに変換する。
戻り値 :
quaternion
引数 :
float3 : オイラー角
参照 :
euler_from_quaternion
クォータニオンとオイラー角は一意に変換できないため、euler_from_quaternion()で逆変換をしても同じ値にはならない。
#(1.0, 0.0, 0.0)のクォータニオンを出力する
print xshade.quaternion_from_euler((1.0, 0.0, 0.0))
quit
Shade 3D を終了する。
xshade.quit()
save_color_list_1
カラーリスト1を保存する。
引数 :
file_path
参照 :
load_color_list_1
#カラーリスト1の設定を保存する
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(False, '*.shdclt|shdclt')
xshade.save_color_list_1(file_path)
save_color_list_2
カラーリスト2を保存する。
引数 :
file_path
参照 :
load_color_list_2
#カラーリスト2の設定を保存する
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(False, '*.shdclt|shdclt')
xshade.save_color_list_2(file_path)
save_shortcut
ショートカット設定を保存する。
引数 :
file_path
参照 :
load_shortcut
#ショートカットの設定を保存する
dialog = xshade.create_dialog_with_uuid()
file_path = dialog.ask_path(False, '*.shdshc|shdshc')
xshade.save_shortcut(file_path)
show_message_box
メッセージボックスを表示する。
戻り値 :
bool
引数 :
string : メッセージ
引数 :
bool : True : OKボタンとキャンセルボタンが表示される。 : False : OKボタンのみが表示される。
#sample文字列とOK/Cancelボタン付きのメッセージボックスを表示する
xshade.show_message_box('sample',True)
show_yesnocancel_message_box
「はい」「いいえ」「キャンセル」ボタン付のダイアログを表示する。
戻り値 :
int : 1:はい、0:いいえ、-1:キャンセル
引数 :
string
xshade.show_yesnocancel_message_box('準備はよろしいですか?')
sleep
指定した時間 Shade 3D をスリープ状態にする。
引数 :
ms : 1秒は1000ms
#3秒後に「hello」を出力する
xshade.sleep(3000)
print 'hello'
uniscale_rectangle
外接する矩形の内側に接し、縦横比の基準となる矩形と(ほぼ)同じ縦横比を持つ矩形を返す。
戻り値 :
rectangle
引数 :
rectangle : 外接する矩形
引数 :
rectangle : 縦横比の基準となる矩形
#(0,0,100,200)の矩形と(0,0,1,3)の縦横比から矩形を出力する
print xshade.uniscale_rectangle((0,0,100,200),(0,0,1,3))
unmatrix
変換マトリクスから拡大縮小、せん断、回転、直線移動を抽出する。
戻り値 :
vec3
引数 :
mat4
#選択形状の変換マトリクスから拡大縮小、せん断、回転、直線移動を抽出し、出力する
print xshade.unmatrix(xshade.scene().active_shape().transformation)