Last active
September 5, 2015 13:16
-
-
Save nutti/7488c62e1ea4c902b7f1 to your computer and use it in GitHub Desktop.
[Blender] Blenderプラグインの作り方 ref: http://qiita.com/nutti/items/a836391723bd28cd3e4c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# メイン関数 | |
if __name__ == "__main__": | |
register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Blender内部のデータ構造にアクセスするために必要 | |
import bpy | |
# プラグインに関する情報 | |
bl_info = { | |
"name" : "Hoge Plugin", # プラグイン名 | |
"author" : "Piyo", # 作者 | |
"version" : (0,1), # プラグインのバージョン | |
"blender" : (2, 6, 5), # プラグインが動作するBlenderのバージョン | |
"location" : "UV Mapping > Hoge", # Blender内部でのプラグインの位置づけ | |
"description" : "Hoge Fuga Piyo", # プラグインの説明 | |
"warning" : "", | |
"wiki_url" : "", # プラグインの説明が存在するWikiページのURL | |
"tracker_url" : "", # Blender Developer OrgのスレッドURL | |
"category" : "UV" # プラグインのカテゴリ名 | |
} | |
# メニュー | |
class CHoge(bpy.types.Operator): | |
bl_idname = "uv.hoge" # ID名 | |
bl_label = "Hoge Menu" # メニューに表示される文字列 | |
bl_description = "Hoge Piyo" # メニューに表示される説明文 | |
bl_options = {'REGISTER', 'UNDO'} | |
# 実際にプラグインが処理を実施する処理 | |
def execute(self, context): | |
return {'FINISHED'} # 成功した場合はFINISHEDを返す | |
# メニューを登録する関数 | |
def menu_func(self, context): | |
self.layout.operator("uv.hoge") # 登録したいクラスの「bl_idname」を指定 | |
# プラグインをインストールしたときの処理 | |
def register(): | |
bpy.utils.register_module(__name__) | |
bpy.types.VIEW3D_MT_uv_map.append(menu_func) | |
# プラグインをアンインストールしたときの処理 | |
def unregister(): | |
bpy.utils.unregister_module(__name__) | |
bpy.types.VIEW3D_MT_uv_map.remove(menu_func) | |
# メイン関数 | |
if __name__ == "__main__": | |
register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Blender内部のデータ構造にアクセスするために必要 | |
import bpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# プラグインに関する情報 | |
bl_info = { | |
"name" : "Hoge Plugin", # プラグイン名 | |
"author" : "Piyo", # 作者 | |
"version" : (0,1), # プラグインのバージョン | |
"blender" : (2, 6, 5), # プラグインが動作するBlenderのバージョン | |
"location" : "UV Mapping > Hoge", # Blender内部でのプラグインの位置づけ | |
"description" : "Hoge Fuga Piyo", # プラグインの説明 | |
"warning" : "", | |
"wiki_url" : "", # プラグインの説明が存在するWikiページのURL | |
"tracker_url" : "", # Blender Developer OrgのスレッドURL | |
"category" : "UV" # プラグインのカテゴリ名 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# メニュー | |
class CHoge(bpy.types.Operator): | |
bl_idname = "uv.hoge" # ID名 | |
bl_label = "Hoge Menu" # メニューに表示される文字列 | |
bl_description = "Hoge Piyo" # メニューに表示される説明文 | |
bl_options = {'REGISTER', 'UNDO'} | |
# 実際にプラグインが処理を実施する処理 | |
def execute(self, context): | |
return {'FINISHED'} # 成功した場合はFINISHEDを返す |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# メニューを登録する関数 | |
def menu_func(self, context): | |
self.layout.operator("uv.hoge") # 登録したいクラスの「bl_idname」を指定 | |
# プラグインをインストールしたときの処理 | |
def register(): | |
bpy.utils.register_module(__name__) | |
bpy.types.VIEW3D_MT_uv_map.append(menu_func) | |
# プラグインをアンインストールしたときの処理 | |
def unregister(): | |
bpy.utils.unregister_module(__name__) | |
bpy.types.VIEW3D_MT_uv_map.remove(menu_func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# メイン関数 | |
if __name__ == "__main__": | |
register() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment