As Blender scripts grow in size, it's time to use the debugger. Until now, when I created a Blender script, I used to focus on self.report, so I was feeling the limits. So I used ** Eclipse + PyDev ** to build a debug environment for Blender script development.
Download the latest version of Eclipse from the Eclipse home page.
You may be prompted to install Java SE if needed, in which case follow the instructions to install.
Follow the steps below to install ** PyDev **.
Help
-ʻInstall New Software ...` in the ʻAvailable Software
windowName
and ** http://pydev.org/updates ** for Location
and click ʻOK`.PyDev
will be added to the ʻAvailable Software window. After selecting it, uncheck the
Contact all update sites during install to find required softwareand click
Next>`.Contact all update sites during install to find required software
, it will take a long time to reach 5. **.
(Reference: Stackoverflow)Next>
in the ʻInstall Details` window.Finish
after accepting the license in the Review Licenses
window.Create a project for debug execution.
File
-- New
--Project ...
Select a wizard
window, select PyDev
-PyDev Project
and clickNext>
Project name
an appropriate name and then clickNext>
Finish
Project
-- Properties
PyDev --PYTHONPATH
from the menu on the leftCreate a source to connect to the PyDev debug server. Place the created source in the same directory ** as the Blender script you are debugging **.
debug.py
import sys
DEBUGGING = True
def start_debug():
if DEBUGGING is True:
PYDEV_SRC_DIR = "(Path to eclipse directory)/plugins/org.python.pydev_XXXXX/pysrc" #Need to be rewritten according to the environment
if PYDEV_SRC_DIR not in sys.path:
sys.path.append(PYDEV_SRC_DIR)
import pydevd
pydevd.settrace()
print("started blender script debugging...")
To start debugging, add start_debug ()
to ** where to start debugging ** in the script you are debugging.
For example, if you want to start debugging immediately after starting script execution, do as follows.
start_debug_at_main.py
from . import debug
if __name__ == "__main__":
debug.startdebug()
Add Blender to an external tool in Eclipse. Here's how to add it:
Run
--ʻExternal Tools --ʻExternal Tools Configurations ...
Program
Main
tab and enter ** Blender executable file ** in Location
and ** the directory where the Blender executable file is located ** in Working Directory
.
Enter your favorite name in Name
(here, ** New_Configuration **)Start the PyDev debug server. The startup procedure is shown below.
Window
--ʻOpen Perspective --ʻOther ...
Debug
to open the Debug perspectivePydev
-- Start Debug Server
to start the serverFollow the steps below to launch Blender from Eclipse.
Run
--ʻ External Tools`-** New_Configuration **Based on the explanation so far, I created a Blender script and debugged it.
With this feeling, you can proceed with debugging using Eclipse when you start debugging.
I was thinking of doing it someday, but I was able to cooperate with Blender and the debugger without any particular addiction. Using a debugger ** will greatly improve development efficiency compared to self.report debugging **, so why not try it out?
Recommended Posts