I’m trying to run a startup file when switching to a custom application template, but it isn’t properly working.
What I’m trying to do is e.g. set the UI size and some File Paths/Folder settings on startup of the custom template.
If I run multiple variants of this code in the script editor it works every time:
But if I add this as “init.py” to the template folder, and switch templates, it does not set the UI scale, and will not reset the temporary folder path.
Also, it does not switch back to the default preferences from the user templates (e.g. General), after opening it. It pick up the settings from the last opened custom template.
What am I missing here? I feel I’m almost there, and would be so useful to have working…
Turning off/on the autosave for Preferences doesn’t make any difference here.
Which I just realized you did, but the __ was interpreted as bold. Hm in this case I don’t know, the documentation is a bit vague on:
“Preferences: Only certain preferences from a template are used”
It doesn’t specify if this limitation is for the config.blend or for also the python script. I would recommend you first trying to change something else via your script (e.g., the theme) to see if things are working.
As a workaround if you do bpy.ops.wm.save_userpref() in your script it may work.
I don’t understand why this is borderline user support…
And in the future, it would be nice if someone just says so straight away, so I can try to find my answer some where else…
I’m trying to program certain functionality into Blender, which is not working properly, AND the docs aren’t really helping either.
Where else can I ask questions like this? RightClick? please…
Or Discord? Same thing.
Like I said, if i run things from the script editor inside Blender it all works as expected. The moment you try this on runtime, it all fails. For me this is extremely frustrating as there is almost no documentation.
I try to figure this stuff out mostly without trying to bother people here, but sometimes I have no other place to go to get direct answers…
But thanks for your reply, will have a look at this as well.
If you want your app-template to have it’s own defaults that are generated dynamically and don’t need to be in the blend files (startup.blend and userdef.blend) it can be done with:
bpy.app.handlers.load_factory_preferences_post for preferences.
bpy.app.handlers.load_factory_startup_post for the startup scene and data.
This way, the user can change the settings you’ve defined if they wish, but loading factory settings can get them back.