[Bf-python] Embedding Blender - XEmbed protocol

Dietrich Bollmann diresu at web.de
Mon Jul 26 14:52:23 CEST 2010


Hi Goat Man :)

On Sun, 2010-07-25 at 22:57 -0700, Goat Man wrote:
> Thats pretty awesome Dietrich, i hope it finds its way into official
> blender in some form.

Thanks :)  But unfortunately it didn't find the way into the official
blender version until now, as my approach to code everything from
scratch was not appreciated and I still couldn't find the time to
rewrite it using some library to get rid of my low-level stuff.  On the
corresponding page on the blender patch tracker
https://projects.blender.org/tracker/index.php?func=detail&aid=6887&group_id=9&atid=127 is more information about why the patch was not integrated.

I also would be happy to get some form of command port functionality
integrated into blender, be it my code, some modified version of it
using some message queue for example at the place of my low-level code
or whatever other implementation somebody else has to offer.

> But is your system one-way only?  How do you get return values from
> functions back into, in your case emacs?

It is two-way.  I temporarily redirect stdout and stderr into string
buffers before evaluating the code and send them back to the client :) 

In emacs I use a slightly modified python mode and, at the place of the
normal "python" command, wrap the blender shell client "blash".  This
works as "blash" behaves the same way as a normal python shell.  

For my lisp client I translate lisp to python code strings when sending
commands to blender and later parse the output of the shell and
translate it back into lisp code (only the subset I need which is small:
I basically code everything as python dictionaries which are interpreted
on server side to generate the 3D models etc.).  Before switching to
Blender I used the Maya command port which basically worked the same
way.  That's where I got the idea to do it like this...

If you are interested, you can read more about the simple protocol I use
to send python code / get back the results (stdout and stderr) here:
http://formgames.org/blender/command-port/#bcp-protocol

When using the command port from python I have to generate the python
command strings and parse the responses in the same way I described
concerning my lisp client.  A "hello world" Python client is here:
http://formgames.org/blender/command-port/#hello-world-python-client It
would be much nicer of course to have a proxy bpy class generating the
command port input and parsing the output as you wrote in your second
email.

Both links are for blender 2.4* as I couldn't find the time necessary to
update the page yet, but the code for 2.5 is similar (using Python 3.1
at the place of 2.5).  

> I'm working on a solution for getting return values, and doing
> callbacks.  My target is RPython (PyPy), i haven't started on bpy yet
> though, but i have gotten pygtk, pyode, and pygame partly working, so
> i am sure the solution is general enough to handle bpy.

That sounds and looks pretty awesome also :)  What do you intend to use
your code for?

Good luck (and fun of course), Dietrich


> http://pastebin.com/rWEfgMSN
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python





More information about the Bf-python mailing list