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 upenter image description here

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

#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 

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 ?

  • $\begingroup$ You mean this bpy.context.workspace.name and [ws.name for ws in bpy.data.workspaces]? $\endgroup$
    – lemon
    Sep 7, 2019 at 6:27
  • $\begingroup$ @lemon sorry for being unclear. i was referencing drop down presets. $\endgroup$
    – Fox
    Sep 7, 2019 at 11:09
  • $\begingroup$ @lemon i updated the question/descritption $\endgroup$
    – Fox
    Sep 7, 2019 at 12:05
  • 1
    $\begingroup$ 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). $\endgroup$
    – lemon
    Sep 7, 2019 at 12:53
  • 1
    $\begingroup$ It’s the bl_label of the preset menu. $\endgroup$
    – AFWS
    Oct 11, 2019 at 21:11

2 Answers 2


Thanks to @AFWS


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


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .