Automatically run the UI script on file load

I don't know for previous versions but in Blender 5.1, I've had an extra step to do to get the ui script to be executed automatically when opening my file:
in the text editor on luna_rig_ui.py, enter the 'Text' menu and enable 'Register'.
It was not e feature targeted in the video but it matches what one would get using Rigify (and avoid having to access the script to run it manually every time the file is loaded)

2 loves
Reply
  • Guillaume Taton(guihom3d) replied


    1 love
  • coyo (coyohti) replied

    I believe registering a script was a feature added recently due to a surge of cases where bad actors were sneaking malicious code into publicly available Blender files. So if one had set a preference to have Blender automatically run scripts things could go horribly wrong opening the wrong file.

    We just can't have nice things, can we.

    2 loves
  • Dwayne Savage(dillenbata3) replied

    Register has been apart of Blender scripting for a long time. At least since 2.76 which was the first version I used, because it was the last version to work on windows XP. It use to be on the header and now is in the menu. This in combination with auto run python option in preferences->files for older versions and preferences->Save & Load in newer version. There is also something you have to do to attach the script so that it will automictically append when you link the rig to another blend file. 

    bpy.context.object['ui_script'] = bpy.data.texts['Your_UI_Script_Name']

    According to my notes Wayne discusses this around 6:20 point on this Video of the Off-Road course. I haven't finished the RIG course, but I have a note from a friend that Wayne teaches another way to do this in the RIG course I'm assuming it's probably in this video: https://cgcookie.com/lessons/luna-ui-and-final-touches I'm only halfway thru chapter 3 and haven't got to that part yet. 

    3 loves
  • Wayne Dixon replied

    dillenbata3, yes there is an easier way now.  You can actually do this through the UI in the custom property section.

    As for the Register.  Yes, I think that is ok to enable when you save the file. (I can't remember if I mention that in the course)

    However, on the user level I strongly recommend that you do not enable "Auto Run Python Scripts" -especially if you're on Windows.

    This will show a popup every time you open a file and that 'Register' option is enabled on a script.  It will warn you saying "Hey this script wants to run, is that ok?"
    And you can check it out before you decide (by jumping to it in the script editor)

    Most of the time it will just be a python ui script...but there has been some nefarious actors out there.  Especially for pirated add-ons being injected with code that will do bad stuff.  Or people pretending to be the legitimate authors and saying "here's an update for you".

    So it's best to stay safe.

    Register is fine.
    Auto run is not fine.



    3 loves