Hello,
I understand that I need to use EnumProperty
but can’t figure it out how to convert existing code…
import bpy
from bpy.types import Panel, Operator, Menu
# Add-on info
bl_info = {
"name": "Action Centers",
"author": "APEC",
"version": (1, 0),
"blender": (2, 81, 0),
"location": "View3D > Properties > AC",
"description": "Action Centers like in Modo.",
"wiki_url": "",
"tracker_url": "",
"category": "3D View"
}
###########################################################################################
################################### Functions #############################################
###########################################################################################
# Action Center NONE setup
def actioncenter_none():
bpy.context.scene.tool_settings.use_snap_scale = False
bpy.context.scene.tool_settings.use_snap_rotate = False
bpy.context.scene.tool_settings.use_snap_align_rotation = False
bpy.context.scene.tool_settings.use_snap_align_rotation = False
bpy.context.scene.tool_settings.snap_elements = {'INCREMENT'}
bpy.context.scene.tool_settings.use_snap = False
bpy.context.scene.tool_settings.transform_pivot_point = 'MEDIAN_POINT'
bpy.context.scene.transform_orientation_slots[0].type = 'GLOBAL'
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
override = bpy.context.copy()
override['area'] = area
bpy.ops.view3d.snap_cursor_to_center(override)
break
# Action Center Element setup
def actioncenter_element():
bpy.context.scene.tool_settings.use_snap = True
bpy.context.scene.tool_settings.snap_elements = {'EDGE'}
bpy.context.scene.tool_settings.use_snap_translate = True
bpy.context.scene.tool_settings.use_snap_rotate = True
bpy.context.scene.tool_settings.use_snap_scale = True
bpy.context.scene.tool_settings.use_snap_align_rotation = True
bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR'
bpy.context.scene.transform_orientation_slots[0].type = 'CURSOR'
###########################################################################################
################################### Operators #############################################
###########################################################################################
# Create NONE Action Center
class ACNONE_OT_create_acnone(Operator):
bl_idname = "acnone.create_acnone"
bl_label = "NONE"
bl_description = "Reset to Default"
def execute(self, context):
actioncenter_none()
return {'FINISHED'}
# Create Element Action Center
class ACELEMENT_OT_create_acelement(Operator):
bl_idname = "acelement.create_acelement"
bl_label = "Element"
bl_description = "Set Action Center to Element mode"
def execute(self, context):
actioncenter_element()
return {'FINISHED'}
###########################################################################################
##################################### The UI ##############################################
###########################################################################################
# Action Center Panel
class ACTIONCENTERS_PT_main(Panel):
bl_label = "Action Centers"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = 'AC'
def draw (self, context):
layout = self.layout
row = layout.row()
col = layout.column(align=True)
row.label (text="Select AC")
#draw buttons
col.operator("acnone.create_acnone", icon = 'WORLD_DATA')
col.operator("acelement.create_acelement", icon = 'WORLD_DATA')
def register():
bpy.utils.register_class(ACTIONCENTERS_PT_main)
bpy.utils.register_class(ACNONE_OT_create_acnone)
bpy.utils.register_class(ACELEMENT_OT_create_acelement)
def unregister():
bpy.utils.unregister_class(ACTIONCENTERS_PT_main)
bpy.utils.unregister_class(ACNONE_OT_create_acnone)
bpy.utils.unregister_class(ACELEMENT_OT_create_acelement)
if __name__ == "__main__":
register()
This is a simple set of actions turned to buttons for one clicking. No extra coding or math.