5
$\begingroup$

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.

$\endgroup$

2 Answers 2

5
$\begingroup$

There are two things you need to do -

  1. 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.

enter image description here

  1. Ensure that Auto-Run Python Scripts is enabled in your preferences.

enter image description here

$\endgroup$
3
  • $\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$
    – Mo Hossny
    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$
    – sambler
    Commented 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$
    – Sparkette
    Commented May 2, 2021 at 1:33
2
$\begingroup$

In blender 2.8x it's the same things to do :

  1. rename your script file in the text editor with .py at the end
  2. check register in the Text menu (this option is greyed out until you rename your file)

enter image description here

$\endgroup$

You must log in to answer this question.

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