Blenderでスクリプティング機能を使用する人の中には、外部のPythonファイルを実行したいと考える人もいるのではないでしょうか。
今回は、外部のPythonファイルをBlender内で実行する方法をご紹介します。
外部のPythonファイルを実行する手順
Blenderで外部のPythonファイルを実行するには、次のようにします。
まず、エディタータイプの中から「Scripting > テキストエディター」を選択します。

<開く>を押して、実行したいPythonファイルを選択します。

あとは再生ボタンを押せば実行できます。

エラーが発生した場合の対処法
Pythonファイルを実行すると、次のようなエラーが表示される場合があります。

エラーの原因を知るために、コンソールを開きます。
メニューから「ウィンドウ > システムコンソール切替え」を選択してください。

別ウィンドウでコンソールが開かれます。
エラーの内容を確認してください。

Blenderのウィンドウに戻って、エラー内容にしたがって修正を加えます。
複数行のPythonスクリプトが実行できて便利
ScriptingタブからPythonを実行しようとすると、基本的に1行ずつしか実行できません。

Scriptingタブにあるコンソールは次のように1行ずつ実行する形式になっています。

複数行のPythonスクリプトを実行したいときは、テキストエディターというエディタータイプを使うといいことを覚えておくと便利です。
コメント