0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Substance 3D PainterとPyCharmを接続してデバッグしやすくする

Posted at

環境

  • Windows
  • Adobe Substance 3D Painter 10.1.2
  • PyCharm 2024.3.4

設定手順

デバッグ構成の作成

Remote debugging with the Python remote debug server configuration の手順にしたがってリモートデバッグ用の構成を作成します。

まず、メニューの Run| Edit Configurations... から Run/debug configurations ダイアログを開き、+ボタンをクリックして Python Debug Server を選択します。

次に設定値を入力します。

  • IDE host name: localhost
  • Port: 空いている番号

設定値を入力すると、この後の接続手順で必要となる情報が設定値に合わせて表示されます。1の手順のコマンドと2の手順のPythonコードをメモしてください。

画像では port の箇所が $SERVER_PORT になっていますが実際は入力した値が表示されます。

ライブラリのインストール

メモした手順の1のコマンドで pydevd-pycharm パッケージをインストールしてください。

pip install pydevd-pycharm~=243.25659.43

接続手順

まずPyCharm のデバッグボタンを押します。

PyCharmのConsoleに「Waiting for process connection...」と表示され接続待ちの状態になったことを確認します。

Substance 3D Painter の Python Console にメモした手順2のコードを実行します。

import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=<port number>, stdoutToServer=True, stderrToServer=True)

PyCharmのConsoleに「Connected to pydev debugger」と表示されれば接続成功です。

接続直後はSubstance 3D Painter が一時停止状態となり、操作ができなくなります。
Resume Program のボタンを押すとSubstance 3D Painter の一時停止が解除され操作できるようになります。

接続に関しての簡単な補足

接続中はブレークポイントの設定が有効になります。
Substance 3D Painter の Python Console から呼び出して実行すれば、ブレークポイントで一時停止し変数の確認が可能です。

またPause中はPyCharmのConsole上で Substance 3D Painter の Python APIを実行することが可能です。
Substance 3D PainterのPython Consoleと異なり、複数行のコードをコピーペーストして実行することも可能です。

停止方法

PyCharm で Stop ボタンを押します。

また、Substance 3D Painter の Python Console で下記のコードを実行します。

pydevd_pycharm.stoptrace()

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?