kanta's spike

作成した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!!

参考

作成日: 2022/11/25