[IPython-User] Possible to interface Blender?
Thu Jun 28 04:55:08 CDT 2012
Thanks Fernando, I appreciate the help you provided and your time. I
looked at the code, thanks for pointing me to the right spot, but let
me learn about Blender event loop first and maybe I can make some
patchwork from those examples.
In the meantime, I mailed one of the many Blander lists, and although
I didn't get advise on hooking Blender's event loop at this moment, a
member suggested to avoid dealing with Blender keymap definitions (by
trying embed process inside Blender) and instead to simply run Python
embed script in background while starting Blender, which would look
like this in terminal:
./blender -b -P shell.py
where shell.py is "from IPython import embed; embed()".
This is interesting tip - by executing above line, I'm left in IPython
terminal console where I can get Blender namespace by importing "bpy",
and it's very similar as if Blender was compiled as Python module.
Exiting IPython console returns in terminal, and Blender GUI is not
available at any time in the process.
This shows other idea - instead trying impossible at the moment
because of lack of knowledge for both parties, try to embed IPython
kernel and then try to attach from various IPython app interfaces,
while being aware that main point of interacting with Blender GUI tool
is not available just now (yet). This is potentially interesting as
now user doesn't need to compile Blender specifically as Python module
to be able to use it from arbitrary Python interface, but any user can
So I changed shell.py to "from IPython import embed_kernel;
embed_kernel()" which leaves me with IPython kernel running. Using
current ipython 0.13dev I get this terminal output:
[IPKernelApp] --existing kernel-4915.json
with possibility to import bpy. Some observations/questions on it:
1. According documentation I could run "ipython <app> --existing" and
hook to kernel, but while I can do this for console and qtconsole,
running "ipython3 notebook --existing" complains about invalid flag
2. I can also run "ipython console --existing" and import "bpy"
(Python3 module) with running Python 2 ipython. How is it possible, or
allowed, or what does it mean?
3. For some unfortunate reason TAB key doesn't work. Can I do
something from IPython side to workaround it?
4. The idea is also to wrap couple of simple function in startup
ipython wrapper, like displaying rendered result inline. Some problem
does not allow doing this with existing png image, as shown in
After generating attached screenshot I see IPython raises this:
Traceback (most recent call last):
File "/.../qt/base_frontend_mixin.py", line 109, in _dispatch handler(msg)
File "/.../qt/console/rich_ipython_widget.py", line 126, in _handle_pyout
File "/usr/lib/python3.2/base64.py", line 367, in decodestring
File "/usr/lib/python3.2/base64.py", line 360, in decodebytes
binascii.Error: Incorrect padding
5. How can I terminate attached kernel? ^C, ^D, ... can't do it.
Thanks for any help
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 68333 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/ipython-user/attachments/20120628/681932df/attachment-0001.png
More information about the IPython-User