Blender's Python editor is functional, but not the best available. The tools and guidelines in this repository are for connecting Blender to Eclipse, bringing superior tools to bear on your Blender scripts.
These tools build on the instructions on the Blender Wiki and the original book of Eclipse/Blender instructions by Witold Jaworski.
Advantages include:
pydevd.settrace()
calls.NOTE: These instructions assume for the sake of example that Blender
is version 2.77 and that it's installed on OSX at
/Applications/Blender/blender.app
, but it should not be hard to work
out how to adapt the paths in this document to match your own installation.
cd path/to/repo ; git clone
'https://github.com/georgevdd/blender-eclipse.git'
.
These steps should only need to be done once per Eclipse installation.
TODO: Make an Eclipse plugin that does these steps, or at least checks that they've been done.
git clone
'https://github.com/mutantbob/pycharm-blender.git'
.
/Applications/Blender/blender.app/Contents/MacOS/blender -b -P python_api/pypredef_gen.py
This will create a directory called pypredef
which will be useful
when setting up the Python interpreter, next.
NOTE: Something that Jaworski's book doesn't mention: You can use assert isinstance(x, XType)
or if isinstance(x, XType):
to help PyDev
reason about the types of variables. With Python 3.5 or later you can use type hints too.
TODO: bring pypredef_gen.py
into this repository and make
running it easier.
The Python interpreter that Eclipse will use needs to be the same version as the one that Blender uses. The easy way to achieve that is to set up Eclipse to use the interpreter that comes with Blender:
Blender Python3
or whatever you like/Applications/Blender/blender.app/Contents/Resources/2.77/python/bin/python3.5m
OK
.lib
directory. Click OK
to accept everything it finds in there.pypredef
directory which was created in the
previous section.These steps need to be done for each Eclipse PyDev project that you want to use with Blender.
TODO: Make an Eclipse plugin that does these steps, or at least checks that they've been done.
Blender Python3
RClick PyBlend -> Run As -> Run Configurations ...
Blender Subprocess
PyBlend
/Applications/Blender/blender.app/Contents/MacOS/blender
Arguments
--window-geometry 960 0 960 10000
/Users/georgevdd/src/blender/eclipse_blend.blend
--addons eclipse_connector
You can omit the path to a .blend
file if you'd rather start
with whatever Blender thinks your default startup file is.
Also the --window-geometry
setting is optional; I use it
to make the Blender window show up where it doesn't cover my
Eclipse workspace.
Environment
PYDEV_SRC_PATH
: ${bundle_location:org.python.pydev.core}/pysrc:${bundle_location:org.python.pydev}/pysrc
This setting tells the Eclipse Connector for Blender where it should find the PyDev source code.
NOTE: The new Run Configuration must be given a valid "Project" field, otherwise it will silently not set up its environment variables properly. It's not clear to me why this is.
These steps should only need to be done once per Blender installation.
cd /Users/georgevdd/Library/Application Support/Blender/2.77/scripts/addons
ln -s path/to/repo/eclipse_connector.py .
Launch Blender from Eclipse
PyBlend
projectStandard output from Blender should appear in the Eclipse console view. You should see a small amount of logging from Eclipse Connector.
If you make changes to a Python script in Eclipse after you have run the script in Blender, Blender will not automatically notice those changes. The next time you try to run the script in Blender, you will see that it runs the old code. (This is because Blender is secretly less of a graphics program with a Python subsystem in it, than a Python interpreter with a graphics subsystem in it.)
To work around this, have Blender run the script indirectly by Executing External Scripts.