bl_info = { "name": "My Script", # スクリプト名。アドオンメニューに表示される。 "description": "Single line explaining what this script exactly does.", # 説明。 "author": "John Doe, Jane Doe", # 作成者 "version": (1, 0), # このアドオンスクリプトのバージョン "blender": (2, 65, 0), # 実行可能な最低のBlenderバージョン。例では Blender2.65 "location": "View3D > Add > Mesh", # メニューの場所の説明? "warning": "", # used for warning icon and text in addons panel # 警告アイコンとテキスト。バグやエラーが発生した時に表示される。 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/" # wiki URL "Scripts/My_Script", "category": "Add Mesh"} # スクリプトのカテゴリ。定義されているカテゴリを選択。
# 登録 def register(): bpy.utils.register_class(OBJECT_sample) # オペレータクラスを登録 bpy.types.VIEW3D_MT_object.append(sample_button) # ボタンを登録 # 解除 def unregister(): bpy.utils.unregister_class(OBJECT_sample) # オペレータクラスを解除 bpy.types.VIEW3D_MT_object.remove(sample_button) # ボタンを解除 if __name__ == "__main__": register()
class OBJECT_sample(bpy.types.Operator): """Sample Operator""" bl_idname = "object.sample" bl_label = "Sample" bl_options = {'REGISTER'} def execute(self, context): #オペレータが呼び出されたとき、この関数が実行されます print("Sample message") return {'FINISHED'}
def sample_button(self, context): self.layout.operator( OBJECT_sample.bl_idname, text="Sample")