I’ve managed to hobble this together, for some reason the enum isn’t changing and always sticking to LOC, why please?
bl_info = {
"name": "tester",
"description": "",
"author": "",
"version": (0, 0, 1),
"blender": (2, 60, 8),
"location": "3D View > Toolbox",
"warning": "", # used for warning icon and text in addons panel
"wiki_url": "",
"tracker_url": "",
"category": "Test"
}
import bpy
import mathutils
import math
from bpy.props import *
from bpy.props import (StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
EnumProperty,
PointerProperty,
)
from bpy.types import (Panel,
Operator,
AddonPreferences,
PropertyGroup,
)
def my_settings_callback(scene, context):
items = [
('LOC', "Location", ""),
('ROT', "Rotation", ""),
('SCL', "Scale", ""),
]
ob = context.object
if ob is not None:
if ob.type == 'LAMP':
items.append(('NRG', "Energy", ""))
items.append(('COL', "Color", ""))
return items
class MySettings(PropertyGroup):
# apply values to LOC ROT SCL
transform = EnumProperty(
name="Apply Data to:",
description="Apply Data to attribute.",
items=my_settings_callback
)
#bpy.context.scene.mytest = "mmmmmmmm"
class OBJECT_OT_Button(bpy.types.Operator):
bl_idname = "my.button"
bl_label = "This is the Button Label"
def execute (self, context):
#bpy.context.scene.my_string_prop = "Start Server clicked!"
print("Clicked button") #, bpy.context.scene["mytest"])
#print(dir(context.scene.my_tool))
#print(context.scene.my_tool.transform['EnumProperty'])
print(context.scene.my_tool.transform)
return {'FINISHED'}
class MESH_OT_wc_test(bpy.types.Operator):
bl_idname = "mesh.wc_test"
bl_label = "WC TEST LABEL"
bl_options = {'REGISTER','UNDO'}
def execute(self, context):
print("executing....")
return {'FINISHED'}
def invoke(self, context, event) :
#self.action_common(context)
print("invoking....")
return {"FINISHED"}
inverted = bpy.props.BoolProperty \
(
name = "Upside Down",
description = "Generate the tetrahedron upside down",
default = False
)
def draw(self, context) :
TheCol = self.layout.column(align = True)
TheCol.prop(self, "inverted")
mytool = context.scene.my_tool
TheCol.prop(mytool, "transform", text="")
#TheCol.prop(Button, "wow", text="")
TheCol.operator("my.button", text="Start Server")
#self.layout.operator("hello.hello", text='Hej').country = "Sweden"
#@classmethod
#def poll(self,context):
# return context.object is not None
def menu_func(self, context):
print("Do something")
self.layout.operator("mesh.wc_test", text="WC", icon='MESH_TORUS')
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_mesh_add.prepend(menu_func)
bpy.types.Scene.my_tool = PointerProperty(type=MySettings)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_mesh_add.remove(menu_func)
if __name__ == "__main__":
#unregister()
register()