0

I can't understand how to get the value of an EnumProperty outside this operator. This is an example with the panel where I would like to show the current value of this EnumProperty:

class SearchEnumOperator(bpy.types.Operator):
    bl_idname = "object.search_enum_operator"
    bl_label = "Search Enum Operator"
    bl_property = "my_search"

    my_search: EnumProperty(
        name="My Search",
        items=(
            ('FOO', "Foo", ""),
            ('BAR', "Bar", ""),
            ('BAZ', "Baz", ""),
        ),
    )

    def execute(self, context):
        self.report({'INFO'}, "Selected:" + self.my_search)
        return {'FINISHED'}

    def invoke(self, context, event):
        context.window_manager.invoke_search_popup(self)
        return {'RUNNING_MODAL'}

class CustomMenu(bpy.types.Menu):
    bl_label = "Custom Menu"
    bl_idname = "OBJECT_MT_custom_menu"

    def draw(self, context):

        layout = self.layout
        ###Noob example:
        #layout.label(text = SearchEnumOperator.my_search)<---------?
Noob Cat
  • 1,222
  • 3
  • 20
  • 61
  • 2
    https://blender.stackexchange.com/questions/163129/how-can-i-access-view3d-select-circle-radius-value/163130#163130 – batFINGER May 25 '20 at 10:10
  • Ty for this tips, So actually, it seems like a bad practice, I think I'll have to change my approach to that enumproperty. – Noob Cat May 25 '20 at 10:15
  • 1
    Not sure what you mean re bad practice. If you want to expand the enum in a menu can use layout.operator_menu_enum (or whatever it's called consult docs) as shown somewhat in https://blender.stackexchange.com/a/102157/15543 Might also need to have REGISTER in operator bl_options for it to show up in last operator used. – batFINGER May 25 '20 at 10:23

0 Answers0