blender pannel

Solutions on MaxInterview for blender pannel by the best coders in the world

showing results for - "blender pannel"
Niclas
30 Apr 2019
1import bpy
2from bpy.types import (Panel, Operator)
3
4# ------------------------------------------------------------------------
5#    Operators
6# ------------------------------------------------------------------------
7
8class SimpleOperator(Operator):
9    """Print object name in Console"""
10    bl_idname = "object.simple_operator"
11    bl_label = "Simple Object Operator"
12
13    def execute(self, context):
14        print (context.object)
15        return {'FINISHED'}
16
17# ------------------------------------------------------------------------
18#    Panel in Object Mode
19# ------------------------------------------------------------------------
20
21class OBJECT_PT_CustomPanel(Panel):
22    bl_idname = "object.custom_panel"
23    bl_label = "My Panel"
24    bl_space_type = "VIEW_3D"   
25    bl_region_type = "UI"
26    bl_category = "Tools"
27    bl_context = "objectmode"   
28
29
30    @classmethod
31    def poll(self,context):
32        return context.object is not None
33
34    def draw(self, context):
35        layout = self.layout
36        obj = context.object
37
38        layout.label(text="Properties:")
39
40        col = layout.column(align=True)
41        row = col.row(align=True)
42        row.prop(obj, "show_name", toggle=True, icon="FILE_FONT")
43        row.prop(obj, "show_wire", toggle=True, text="Wireframe", icon="SHADING_WIRE")
44        col.prop(obj, "show_all_edges", toggle=True, text="Show all Edges", icon="MOD_EDGESPLIT")
45        layout.separator()
46
47        layout.label(text="Operators:")
48
49        col = layout.column(align=True)
50        col.operator(SimpleOperator.bl_idname, text="Execute Something", icon="CONSOLE")
51        col.operator(SimpleOperator.bl_idname, text="Execute Something Else", icon="CONSOLE")
52
53        layout.separator()
54
55# ------------------------------------------------------------------------
56#    Registration
57# ------------------------------------------------------------------------
58
59def register():
60    bpy.utils.register_class(OBJECT_PT_CustomPanel)
61    bpy.utils.register_class(SimpleOperator)
62
63def unregister():
64    bpy.utils.unregister_class(OBJECT_PT_CustomPanel)
65    bpy.utils.unregister_class(SimpleOperator)
66
67if __name__ == "__main__":
68    register()
69