I would like to have a few globally available functions which should not not depend on a .blend file.
Is there a place (A setup.py, __init__.py or something like that) where I could put a few lines of code?
Asked
Active
Viewed 7,055 times
16
-
possible duplicate of Can I perform an action when a file is saved or loaded? – wchargin Sep 06 '13 at 16:46
-
This video (https://www.youtube.com/watch?v=A-BOWF82Er4) explains how to easily create an addon but it ssems not to be working on the 2.92 version. – Melodicpinpon May 09 '21 at 20:43
2 Answers
16
As documented in the manual, you can save your script in the scripts/startup/ directory with a .py extension and it will be automatically imported on startup.
quellenform
- 35,177
- 10
- 50
- 133
Aldrik
- 9,720
- 22
- 56
10
If it's for all of your Blender sessions, then you might be best creating a simple add-on with the functions you need.
If it's per .blend file, then you can use Blender's Text Editor within that file, store your python commands there, and enable the Register checkbox in the Text Editor's header. The only caveat to this approach is that you'll need to start Blender with the -y flag so the embedded script will run on start.
Fweeb
- 7,202
- 2
- 32
- 37