![]() ![]() The meaty part of this code are the preset_defines and preset_values properties. If you want to take a peek at the code behind this magic you can find it in /bin/2.81/scripts/startup/bl_operators/presets.py We can also use this operator to remove presets by setting remove_active to True. There’s no need to add an execute() or invoke() function in this case, since the mixin implements them. # Common variable used for all preset values Preset_operator = 'script.execute_preset'Ĭlass OT_AddMyPreset(AddPresetBase, Operator): from bl_operators.presets import AddPresetBase Let’s bring the AddPresetsBase mixin into the mix (hah!). Next we need to make an operator to add/remove presets. The full path would thenīe ~/.config/blender/2.81/scripts/presets/object/my_presets/. For this example let’s use ‘object/my_presets’. This could be your addons name, or a category with your addon as a subfolder. It also brings some extra flexibility on the UI.įirst we have to decide where to save the presets. Using the presets system on panels only takes a bit more work. It will even create a folder for them in the presets directory! (note that you need to save at least one preset for that) For panels class My_OP(Operator):īlender will add the preset menu to the operator UI for you. Just add the PRESET to the bl_options set and you’re done. For operatorsĪdding presets to operators is as simple as it gets. If you want to have images, thumbnails and other advanced features you will have to roll your own system. Also note that the built-in presets system only includes the menu we often see on top of operators and panels. Unfortunately there’s no way of importing/exporting presets yet other than manually copying files (or making an operator that does that). Users//Library/Application/Support/Blender/2.81/scripts/presets/Ĭ:\Documents and Settings\%username%\Application Data\Blender Foundation\Blender\2.81\scripts\presets\ The presets folder is inside your personal Blender scripts folder. This is handled for us, but you might want to keep it mind for other things (like packaging presets). Adding/removing presets involves creating or deleting py files from the presets folder. When you select a preset in the menu that particular script is read from disk and run. Presets are Python files that manually set values. The good news is that it’s Python based and easy to use. ![]() There’s a built-in presets system in Blender used for operators and panels. Looking to add support for presets in your addon? Read on to find out how!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |