ご覧いただき、ありがとうございます。
下のサイトを参考にしながら、Blender API を用いてアドオンを作成しています。
https://nutti.gitbooks.io/introduction-to-add-on-development-in-blender/content/index.html
やりたいこととしましては、3Dビューエリアに画像のようなファイルパス入力欄を作成しようとしています。
3Dビューエリアへの追加は、以下のリンクを参考にしています。
https://nutti.gitbooks.io/introduction-to-add-on-development-in-blender/content/body/chapter_02/09_Control_Blender_UI_2.html
Python
1layout.prop(scene, 'save_path', text="")
で上記の入力欄を作成しています。
しかし、現状作ってみた感じだと、作成したGUIからファイルパスを設定すると、うまく読み込むことができない時があります。
ソースコードは以下のような感じです。
Python
1class File(bpy.types.Panel): 2 bl_label = "file" # タブに表示される文字列 3 bl_space_type = 'VIEW_3D' # メニューを表示するエリア 4 bl_region_type = 'TOOLS' # メニューを表示するリージョン 5 bl_category = "file" # タブを開いたメニューのヘッダーに表示される文字列 6 bl_context = "objectmode" # パネルを表示するコンテキスト 7 8 # 本クラスの処理が実行可能かを判定する 9 @classmethod 10 def poll(cls, context): 11 return True 12 13 # ヘッダーのカスタマイズ 14 def draw_header(self, context): 15 layout = self.layout 16 layout.label(text="", icon='PLUGIN') 17 18 # メニューの描画処理 19 def draw(self, context): 20 layout = self.layout 21 scene = context.scene 22 23 layout.label(text="Path:") 24 layout.prop(scene, 'save_path', text="") # <- ここです!! 25 layout.separator() 26 27 # ボタンを追加 28 layout.operator(py_render.Render.bl_idname, text="render depth images") 29 layout.separator()
Python
1# プロパティの初期化 2def init_props(): 3 scene.save_path = bpy.props.StringProperty( 4 name = "save_path", 5 default = "", 6 description = "Define the save path of the project", 7 subtype = 'DIR_PATH' 8 )
ファイルパスGUIのつけ方をご存知の方、ご教授いただけると幸いです。
よろしくお願いいたします。
あなたの回答
tips
プレビュー