Skip to content

Instantly share code, notes, and snippets.

@p2or
Last active May 22, 2023 16:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save p2or/c40e33ca6f524198e120d9b48463d2f2 to your computer and use it in GitHub Desktop.
Save p2or/c40e33ca6f524198e120d9b48463d2f2 to your computer and use it in GitHub Desktop.
UI - Expand Enum #Blender #BSE
# for http://blender.stackexchange.com/questions/58171/how-to-create-a-boolean-vector-property-that-is-single-selection
bl_info = {
"name": "Add-on Template",
"description": "",
"author": "",
"version": (0, 0, 1),
"blender": (2, 70, 0),
"location": "3D View > Tools",
"warning": "", # used for warning icon and text in addons panel
"wiki_url": "",
"tracker_url": "",
"category": "Development"
}
import bpy
# ------------------------------------------------------------------------
# store properties in the active scene
# ------------------------------------------------------------------------
class MySettings(bpy.types.PropertyGroup):
my_bool = bpy.props.BoolProperty(
name="Enable or Disable",
description="A bool property",
default = False
)
my_axis = bpy.props.EnumProperty(
name="Axis",
description="Description",
items = (('POS_X', "X", ""),
('POS_Y', "Y", ""),
('POS_Z', "Z", ""),
),
default='POS_X'
)
# ------------------------------------------------------------------------
# my tool in objectmode
# ------------------------------------------------------------------------
class OBJECT_PT_my_panel(bpy.types.Panel):
bl_idname = "OBJECT_PT_my_panel"
bl_label = "My Panel"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_category = "Tools"
bl_context = "objectmode"
@classmethod
def poll(self,context):
return context.object is not None
def draw(self, context):
layout = self.layout
scene = context.scene
mytool = scene.my_tool
layout.prop(mytool, "my_bool")
layout.row().prop(mytool, "my_axis", expand=True)
# ------------------------------------------------------------------------
# register and unregister
# ------------------------------------------------------------------------
def register():
bpy.utils.register_module(__name__)
bpy.types.Scene.my_tool = bpy.props.PointerProperty(type=MySettings)
def unregister():
bpy.utils.unregister_module(__name__)
del bpy.types.Scene.my_tool
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment