# How to know the name of the an active preset dropdown?

Hello i created a custom operator preset system.

i'd like to know how to have acces to the name of an active preset. i think an example from any preset in blender could help me in my research.

There's no info about this anywhere.

Here is my set up

This is the code i was able to collect so far

#this is the correct code mut within blender ! no with my addon
bpy.data.window_managers["WinMan"].preset_name = "New Preset"
#call preset menu of nlender ! not my addon
bpy.ops.wm.call_panel(name="CYCLES_PT_sampling_presets")

#add a new preset
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
bpy.ops.wm.call_menu(name="Scatter_MT_C_Slots_PresetMenu")


i need to find the bpy.data.window_managers["WinMan"].preset_name = "New Preset" for my addon menu. i don't know how this is possible ?

• You mean this bpy.context.workspace.name and [ws.name for ws in bpy.data.workspaces]? – lemon Sep 7 '19 at 6:27
• @lemon sorry for being unclear. i was referencing drop down presets. – DB3D Sep 7 '19 at 11:09
• @lemon i updated the question/descritption – DB3D Sep 7 '19 at 12:05
• I'm not skilled at that. But why don't you store the preset identification/name/whatever as an operator property? (not sure there is some Blender mechanism that does it automatically, except maybe by preset path). – lemon Sep 7 '19 at 12:53
• It’s the bl_label of the preset menu. – AFWS Oct 11 '19 at 21:11

## 2 Answers

Thanks to @AFWS

print(bpy.types.CYCLES_PT_integrator_presets.bl_label)


active preset is in fact the name of the bl_label

Adding to the answer of DB3D:

Assuming that panel for the preset uses preset_operator = "script.execute_preset" the selected preset is indeed stored in bl_label. This can be seen in class ExecutePreset(Operator) in the presets.py where the label is changed to the most recent selection when the operator is executed.

    # change the menu title to the most recently chosen option
preset_class = getattr(bpy.types, self.menu_idname)
preset_class.bl_label = bpy.path.display_name(basename(filepath))


The code is licensed under GNU GENERAL PUBLIC LICENSE Version 3