How can you set Blender's Theme Preset with python?
I'm don't mean customize a few colors, I'm talking about loading one of the existing presets.
Is there a simple command I can run?
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.
Sign up to join this communityI found a way but I don't know it is right or wrong to do this way The way I did is - In the dropdown menu of themes just right click on the theme you want to change to and then another menu will appear > click on copy python command > and then paste that command in the console > and if you want to change the theme from the console you need to remember the theme name > you can change the name in the command where the file name is written (maya.xml, or modo.xml, etc).
Step 1-
Step 2-
Step 6 -
And in this way, you can change the theme from the console
Thanks to the other answer I figured this out. It does the same thing but it saves me from typing the entire path which was super long.
I have a script that defines some Blender defaults and since my theme's folder is in the same location I simply load it like this:
# Blender Setup Script
import bpy
import os
file_path = os.path.join(os.path.dirname(__file__), # Path to this script.
'armored_themes/armored_pink.xml') # Relative path to the theme.
bpy.ops.script.execute_preset(
filepath=file_path,
menu_idname='USERPREF_MT_interface_theme_presets')