Skip to content

Instantly share code, notes, and snippets.

@dskjal
Last active April 4, 2018 02:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dskjal/17b74e6fa7e4b348ad51b2709e9d2023 to your computer and use it in GitHub Desktop.
Blender で選択されているオブジェクトがメッシュで名前が Cube の時だけ UI を表示する
import bpy
class UI(bpy.types.Panel):
bl_label = "my panel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
####################################################################################################
@classmethod
def poll(self, context):
o = context.active_object
return o and o.type == 'MESH' and o.name == 'Cube'
####################################################################################################
def draw(self, context):
self.layout.operator("my.button")
class MyButton(bpy.types.Operator):
bl_idname = "my.button"
bl_label = "text"
def execute(self, context):
print("pushed")
return{'FINISHED'}
classes = (
UI,
MyButton
)
for cls in classes:
bpy.utils.register_class(cls)
''' 登録を解除する場合
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment