Hy! How do you get expanded EnumProperty to run?
In my example the operator_menu_enum works well.
The expanded enum property only appears in the panel, but dont work. I tried different ways, but can
t figured it out what is wrong.
Maybe someone could help? Thanks in advance!
import bpy
from bpy import*
from bpy.props import*
#
# Class to define properties
class MyProps(bpy.types.PropertyGroup):
tp_axis = bpy.props.EnumProperty(
items=[("tp_global" ,"Global" ,"Global"),
("tp_local" ,"Local" ,"Local"),
("tp_normal" ,"Normal" ,"Normal"),
("tp_gimbal" ,"Gimbal" ,"Gimbal"),
("tp_view" ,"View" ,"View")],
name = "TP-Axis",
default = "tp_global",
description = "change manipulator axis")
class TP_ORIENT_AXIS(bpy.types.Operator):
"""Transform Axis Orientation"""
bl_idname = "tp_ops.orient_axis"
bl_label = "Transform Axis Orientation"
bl_options = {'REGISTER', 'UNDO'}
tp_axis = bpy.props.EnumProperty(
items=[("tp_global" ,"Global" ,"Global"),
("tp_local" ,"Local" ,"Local"),
("tp_normal" ,"Normal" ,"Normal"),
("tp_gimbal" ,"Gimbal" ,"Gimbal"),
("tp_view" ,"View" ,"View")],
name = "TP-Axis",
default = "tp_global",
description = "change manipulator axis")
def execute(self, context):
if self.tp_axis == "tp_global":
bpy.context.space_data.transform_orientation = 'GLOBAL'
elif self.tp_axis == "tp_local":
bpy.context.space_data.transform_orientation = 'LOCAL'
elif self.tp_axis == "tp_normal":
bpy.context.space_data.transform_orientation = 'NORMAL'
elif self.tp_axis == "tp_gimbal":
bpy.context.space_data.transform_orientation = 'GIMBAL'
elif self.tp_axis == "tp_view":
bpy.context.space_data.transform_orientation = 'VIEW'
return {'FINISHED'}
def draw(self, context):
layout = self.layout.column(1)
box = layout.box().column(1)
row = box.column(1)
row.alignment = 'CENTER'
row.prop(self, 'tp_axis',text=" ", expand =True)
class TP_Panel_AXIS(bpy.types.Panel):
bl_label = "TP_Panel_AXIS"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = 'objectmode'
def draw(self, context):
layout = self.layout
mypropslist = props = context.window_manager.custom_props
col = self.layout.column(align=True)
row = col.row(1)
row.prop(mypropslist, "tp_axis", text=" " , expand = True)
row = col.row(1)
row.operator_menu_enum("tp_ops.orient_axis", "tp_axis", text="Test")
def register():
bpy.utils.register_class(MyProps)
bpy.utils.register_class(TP_ORIENT_AXIS)
bpy.utils.register_class(TP_Panel_AXIS)
bpy.types.WindowManager.custom_props = bpy.props.PointerProperty(type=MyProps)
def unregister():
bpy.utils.unregister_class(MyProps)
bpy.utils.unregister_class(TP_ORIENT_AXIS)
bpy.utils.unregister_class(TP_Panel_AXIS)
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()