How to know the name of the active preset from a created preset dropdown?

Hello.

i created an operator preset system for my addon.

all i want to know is the name is displayed in the active preset info.
(in the first image it’s ‘Very Wow’)

i just want ot write a script like

if active_preset.name = 'Very Wow':
    do_this()

this is a part of the menu, i may need the "Scatter_MT_C_Slots_PresetMenu" bl_idname?

class Scatter_MT_C_Slots_PresetMenu(bpy.types.Menu):
    bl_label = "No Presets Chosen (=Addon prefs Values)"
    bl_idname = "Scatter_MT_C_Slots_PresetMenu"
    preset_subdir = "scatter_presets_custom"
    preset_operator = "script.execute_preset"
    
    draw = bpy.types.Menu.draw_preset

i’m confused. the only example i could find in blender is

bpy.data.window_managers[“WinMan”].preset_name = “New Preset"

this is lal the api related i could find, but it doesn’t help me in my research.

#call preset menu of nlender ! not my addon
bpy.ops.wm.call_panel(name="CYCLES_PT_sampling_presets")


#add a new preset  from my addon
bpy.ops.scatter.custom_slot_preset_add_operator(name="Wow", remove_name=False, remove_active=False)
#execute a preset from my addon
bpy.ops.script.execute_preset(filepath="filepathofthepreset", menu_idname="Scatter_MT_C_Slots_PresetMenu")
#call preset menu  from my addon
bpy.ops.wm.call_menu(name="Scatter_MT_C_Slots_PresetMenu")

i think i need a bpy.context.something.something[“Scatter_MT_C_Slots_PresetMenu.”].preset_name ???

i don’t know how to find this. i’ve been searching for two hours. no result yet

I too have looked for this and can find anything that might help you, sorry!

In my only Add-on to date I built an EnumProperty to display a list of options, I don’t know if that is any help, if it is I can post the code I used. I have to admit I know very little about what you are trying to do.

Cheers, Clock.

1 Like