作成したPythonのスクリプトをBlender起動時に実行したい。
解決策
Blenderをコマンドラインで起動時に、コマンドラインオプション -P
or --python
につづけてでPythonスクリプトのパスを指定すると
指定したPythonスクリプトを実行できる。
例えば、hello.py
を作成して、以下を実行すると、Blender起動時にhello.py
が実行される。
/Applications/Blender.app/Contents/MacOS/Blender -P ./hello.py
もし、hello.py
が以下の内容の場合、
# hello.py
import bpy
print("hello!!")
Blenderで実行すると、ターミナルに以下のようにhello!!
が表示され、BlenderのGeneralが起動される。
/Applications/Blender.app/Contents/MacOS/Blender -P ./hello.py
read prefs: /Users/kanta/Library/Application Support/Blender/3.3/config/userpref.blend
hello!!