Created
January 21, 2018 02:28
-
-
Save daylanKifky/252baea63eb0c39858e3e9b57f1af167 to your computer and use it in GitHub Desktop.
add a panel in blender from where select a bone from an armature
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
#---------------------------------------------------------- | |
# File bone_panel.py | |
#---------------------------------------------------------- | |
import bpy | |
# | |
# Menu in tools region | |
# see https://wiki.blender.org/index.php/Dev:Py/Scripts/Cookbook/Code_snippets/Interface | |
class ToolsPanel(bpy.types.Panel): | |
bl_label = "Pointer prop test" | |
bl_space_type = "VIEW_3D" | |
bl_region_type = "TOOLS" | |
bl_category = "TAB NAME" | |
bpy.types.Scene.pippo = bpy.props.PointerProperty(type=bpy.types.Object) | |
bpy.types.Scene.bone = bpy.props.StringProperty() | |
def draw(self, context): | |
ob = context.object | |
self.layout.operator("usless.test") | |
self.layout.label(text="Some object:") | |
sc = bpy.data.scenes['Scene'] | |
self.layout.prop(sc, "pippo", text="") | |
if sc.pippo: | |
if sc.pippo.type == 'ARMATURE': | |
self.layout.label(text="Bone:") | |
self.layout.prop_search(sc, "bone", sc.pippo.data, "bones", text="") | |
self.layout.prop(ob, "name", text="") | |
# | |
# The Hello button prints a message in the console | |
# | |
class OBJECT_OT_HelloButton(bpy.types.Operator): | |
bl_idname = "usless.test" | |
bl_label = "Say Hello" | |
def execute(self, context): | |
print("Hello world!") | |
return{'FINISHED'} | |
# | |
# Registration | |
# All panels and operators must be registered with Blender; otherwise | |
# they do not show up. The simplest way to register everything in the | |
# file is with a call to bpy.utils.register_module(__name__). | |
# | |
bpy.utils.register_module(__name__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment