I have written up a script for my model. But there is a bit of a problem with it. As in I have to run the script every time I open the file. I want the script to run automatically when I open the blender File.
2 Answers
$\begingroup$
$\endgroup$
3
There are two things you need to do -
- Setup the script in blenders text editor. The name of the text block needs to end with
.py
and the register checkbox needs to be enabled.
- Ensure that Auto-Run Python Scripts is enabled in your preferences.
-
$\begingroup$ Hello. I am looking for a universal solution that is not as part of the blender file. Is there an "autostart.py" type of file that Blender runs when it opens? $\endgroup$ Commented Dec 28, 2017 at 9:44
-
1$\begingroup$ You should ask that as a question, with a bit more info on what you want to achieve. Without modifying blender itself, I think an addon should be able to do what you want, it can setup
bpy.app.handlers
. $\endgroup$– samblerCommented Dec 29, 2017 at 1:02 -
$\begingroup$ For anyone wondering, if someone opens the .blend file and they have the autorun option turned off, it won't just silently fail; it will display a prompt asking the user if it's okay to run the script. $\endgroup$ Commented May 2, 2021 at 1:33
$\begingroup$
$\endgroup$
In blender 2.8x it's the same things to do :
- rename your script file in the text editor with .py at the end
- check register in the Text menu (this option is greyed out until you rename your file)