Skip to main content
deleted 2 characters in body
Source Link
brockmann
  • 12.8k
  • 4
  • 51
  • 94

Yes. Once registered you can use bl_rna.properties to access the name, its type, the items, the description etc... I'd suggest use the python console to test:

>>> test_items = [
...     ("RED", "Red", "", 1),
...     ("GREEN", "Green", "", 2),
...     ("BLUE", "Blue", "", 3),
...     ("YELLOW", "Yellow", "", 4),
... ] 

>>> bpy.types.Scene.my_enum = bpy.props.EnumProperty(name="Foo", items=test_items)
>>> bpy.types.Scene.bl_rna.properties['my_enum'].name
'Foo'
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0]
<bpy_struct, EnumPropertyItem("RED")>
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0].name
'Red'

In case of an operator property, I'd suggest read the values from the operators annotation'sannotation dict:

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    
    my_prop: bpy.props.StringProperty(name="foo")

    def execute(self, context):
        
        # via bl_rna
        print (self.properties.bl_rna.properties['my_prop'].name)
        
        # using annotations
        print (self.__annotations__.items())
        print (self.__annotations__['my_prop'][1]['name'])
        
        return {'FINISHED'}

Yes. Once registered you can use bl_rna.properties to access the name, its type, the items, the description etc... I'd suggest use the python console to test:

>>> test_items = [
...     ("RED", "Red", "", 1),
...     ("GREEN", "Green", "", 2),
...     ("BLUE", "Blue", "", 3),
...     ("YELLOW", "Yellow", "", 4),
... ] 

>>> bpy.types.Scene.my_enum = bpy.props.EnumProperty(name="Foo", items=test_items)
>>> bpy.types.Scene.bl_rna.properties['my_enum'].name
'Foo'
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0]
<bpy_struct, EnumPropertyItem("RED")>
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0].name
'Red'

In case of an operator property, I'd suggest read the values from the operators annotation's dict:

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    
    my_prop: bpy.props.StringProperty(name="foo")

    def execute(self, context):
        
        # via bl_rna
        print (self.properties.bl_rna.properties['my_prop'].name)
        
        # using annotations
        print (self.__annotations__.items())
        print (self.__annotations__['my_prop'][1]['name'])
        
        return {'FINISHED'}

Yes. Once registered you can use bl_rna.properties to access the name, its type, the items, the description etc... I'd suggest use the python console to test:

>>> test_items = [
...     ("RED", "Red", "", 1),
...     ("GREEN", "Green", "", 2),
...     ("BLUE", "Blue", "", 3),
...     ("YELLOW", "Yellow", "", 4),
... ] 

>>> bpy.types.Scene.my_enum = bpy.props.EnumProperty(name="Foo", items=test_items)
>>> bpy.types.Scene.bl_rna.properties['my_enum'].name
'Foo'
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0]
<bpy_struct, EnumPropertyItem("RED")>
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0].name
'Red'

In case of an operator property, I'd suggest read the values from the operators annotation dict:

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    
    my_prop: bpy.props.StringProperty(name="foo")

    def execute(self, context):
        
        # via bl_rna
        print (self.properties.bl_rna.properties['my_prop'].name)
        
        # using annotations
        print (self.__annotations__.items())
        print (self.__annotations__['my_prop'][1]['name'])
        
        return {'FINISHED'}
added 686 characters in body
Source Link
brockmann
  • 12.8k
  • 4
  • 51
  • 94

Yes. Once registered you can use bl_rna.properties to access the name, its type, the items, the description etc... I'd suggest use the python console to test:

>>> test_items = [
...     ("RED", "Red", "", 1),
...     ("GREEN", "Green", "", 2),
...     ("BLUE", "Blue", "", 3),
...     ("YELLOW", "Yellow", "", 4),
... ] 

>>> bpy.types.Scene.my_enum = bpy.props.EnumProperty(name="Foo", items=test_items)
>>> bpy.types.Scene.bl_rna.properties['my_enum'].name
'Foo'
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0]
<bpy_struct, EnumPropertyItem("RED")>
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0].name
'Red'

In case of an operator property, I'd suggest read the values from the operators annotation's dict:

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    
    my_prop: bpy.props.StringProperty(name="foo")

    def execute(self, context):
        
        # via bl_rna
        print (self.properties.bl_rna.properties['my_prop'].name)
        
        # using annotations
        print (self.__annotations__.items())
        print (self.__annotations__['my_prop'][1]['name'])
        
        return {'FINISHED'}

Yes. Once registered you can use bl_rna.properties to access the name, its type, the items, the description etc... I'd suggest use the python console to test:

>>> test_items = [
...     ("RED", "Red", "", 1),
...     ("GREEN", "Green", "", 2),
...     ("BLUE", "Blue", "", 3),
...     ("YELLOW", "Yellow", "", 4),
... ] 

>>> bpy.types.Scene.my_enum = bpy.props.EnumProperty(name="Foo", items=test_items)
>>> bpy.types.Scene.bl_rna.properties['my_enum'].name
'Foo'
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0]
<bpy_struct, EnumPropertyItem("RED")>
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0].name
'Red'

Yes. Once registered you can use bl_rna.properties to access the name, its type, the items, the description etc... I'd suggest use the python console to test:

>>> test_items = [
...     ("RED", "Red", "", 1),
...     ("GREEN", "Green", "", 2),
...     ("BLUE", "Blue", "", 3),
...     ("YELLOW", "Yellow", "", 4),
... ] 

>>> bpy.types.Scene.my_enum = bpy.props.EnumProperty(name="Foo", items=test_items)
>>> bpy.types.Scene.bl_rna.properties['my_enum'].name
'Foo'
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0]
<bpy_struct, EnumPropertyItem("RED")>
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0].name
'Red'

In case of an operator property, I'd suggest read the values from the operators annotation's dict:

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    
    my_prop: bpy.props.StringProperty(name="foo")

    def execute(self, context):
        
        # via bl_rna
        print (self.properties.bl_rna.properties['my_prop'].name)
        
        # using annotations
        print (self.__annotations__.items())
        print (self.__annotations__['my_prop'][1]['name'])
        
        return {'FINISHED'}
Source Link
brockmann
  • 12.8k
  • 4
  • 51
  • 94

Yes. Once registered you can use bl_rna.properties to access the name, its type, the items, the description etc... I'd suggest use the python console to test:

>>> test_items = [
...     ("RED", "Red", "", 1),
...     ("GREEN", "Green", "", 2),
...     ("BLUE", "Blue", "", 3),
...     ("YELLOW", "Yellow", "", 4),
... ] 

>>> bpy.types.Scene.my_enum = bpy.props.EnumProperty(name="Foo", items=test_items)
>>> bpy.types.Scene.bl_rna.properties['my_enum'].name
'Foo'
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0]
<bpy_struct, EnumPropertyItem("RED")>
>>> bpy.types.Scene.bl_rna.properties['my_enum'].enum_items[0].name
'Red'