Autorun a script?

I wrote about my tests with this not long ago, but I am now officially stuck. I know Blender 2.5 can autorum scripts, so that when a .blend file is opened, certain scripts are instantly run, without user interaction. I can switch the permission for this on and off in the preferences. But how do I make a script/file so that it autoruns the code??

in 2.5 - in the text window there is a check box “Register”

it will register this text as a module on loading
(I don’t know 100% what that means)

I dont think that is it. I tried fooling with registering, and it seems that just means the script is available in the Toolbox, to be assigned as a button. You still need to run the script by yourself (by pushing said button). What I need is something that I can have Blender open a file, let the script do some work on it and then open the next file, in which another script does work and then opens the next file, etc., all while I am far away, leaving my computer to do the dirty work. I did it in 2.47 python, and I am pretty sure 2.5 has the option, too. I just need someone to point (or spell) it out to me…

I’m not 100% on what “register this text as a module on loading” means - as I said

but I use this with a few rigs
I have a .py that has extra rig controls that appear in the properties tab
with this selected - it runs the script and it automatically appears in the properties panel on launch
(ie. this is exactly the same as launching the file and then hitting the “Run Script” button for this script)

that is pretty much the extent of my knowledge on auto-running scripts

What type of script are you trying to run?

Hmm… I tried using the register option, but it does nothing for me, for some reason. All I need is for a .blend file to run a print(“Hello”) script on startup, without any action on my part. If that works, I should be able to put in the actual code easy.

I just did a test - and it worked

I wrote a simple script called text.py

print(“Hello”)

then clicked the Register button
saved it and relaunched

and it printed “Hello” to the terminal w/o any action on my part

are you running blender with a terminal window open?

this is not recommended practice.
the idea is to run blender, then run scripts.
but if you feel you must,
make sure you have Auto Run Python Scripts enabled in User Preferences System menu.

This is why people have complained about security issues.
Auto-running of scripts is fine if your using them in house.
The distribution of scripts or .blend files that auto-run scripts on opening the .blend,
has the potential to be a very big problem.
Not only would I never promote such a script, but I frown upon them.
Teaching people to make auto run scripts is folly.

Sorry, but it’s a real issue & telling people how to do it can be kept in house, like the script should be.

To the casual script user.
If you run any .blend file & it’s auto running scripts, let me know.
Whilst there are legitimate case uses, i see no value in it at all.

Brendon.
Scripts Police!

Whilst there are legitimate case uses, i see no value in it at all.

I’ll change this to “Whilst there are legitimate case uses, i see little value in it at all yet.”

waylow: I tried what you describe, but with no result. Autoruns are allowed, terminal window is open, print-script is registered and saved, but on loading, nothing happens. Where do you save the script, and does that have any influence on it??

Meta: The script is legitimate, for inhouse use. Or rather, the method. I use very large scripts in autosequence on multiple files, and I need the computer to load files to work on them, which means autorunning scripts (unless Blender can actually use scripts on files other than what it is currently holding open, but I have no idea how to do that). So with sutorun, I can leave the computer alone for hours, and it will simply open one file after another and run the scripts on them. For example, rendering multiple files, or such things.

I do feel very assured that autorunning has to be activated deliberately, though. The security issues are easy to deduce!

Pipeline, cool, sorry to sound harsh.
The use you point out, is of course, very valid.
:slight_smile:

it seems you will have to have both “auto-run scripts” and the “register” button checked

…and the security issue MA points out is also a problem in Maya, Max and XSI.

It’s definitely worth pointing out, as although it might not be relevant to you in particular, Pipeline, others might search the forums and find this thread.

Let this be a warning to anyone who downloads a blend file and opens it blindly.

its now possible on blener2.53:eyebrowlift: