[Bf-python] Embedding Blender - XEmbed protocol

Stuart Axon stuaxo2 at yahoo.com
Thu Jul 22 19:39:18 CEST 2010


This looks pretty cool.   I've been thinking a bit about a remote graphics 
library that could work with Blender or maybe other things, like remote gimp 
invocations.

Unfortunately I don't have time to write it (and won't for quite a while).


It looks like you could have celery running on both ends and have it handle 
passing the data around, that should sort out some of the limitations.
If you can get dir() and help() working from the remote python, that would be 
really nice for development.

If other types of data can be sent then it opens up some very interesting 
possibilities for integration (using blender as a library from outside apps, and 
possibly integration with other graphics libraries).

Using the Save Runtime functionality could be quite interesting, if that 
contained a script that waited for a connection.


I'd imagine the bpy api letting you either automatically start a blender 
instance, or specify an address and port to connect to one on.






 S++


>
>From: Goat Man <goatman.py at gmail.com>
>To: Blender Foundation Python list <bf-python at blender.org>
>Sent: Thu, July 22, 2010 1:28:08 AM
>Subject: Re: [Bf-python] Embedding Blender - XEmbed protocol
>
>Celery looks like it is mature and has many features, i'm going to look at it 
>more. Thanks Stuart.
>
>
>For maximum speed and simplicity, i have a minimal wrapper that can interact 
>with Blender's python API in a very limited way.  If you can live with one 
>function call per line, and only a single variable returned from functions, 
>source code is here:
>
>
>http://pastebin.com/iPjBpD9P
>
>
>you can create a proxy module "bpy" in the process outside of Blender, 
>operations on bpy get stored in an string that can be executed later in Blender. 
> For example:
>
>
>bpy.ops
>bpy.data.objects
>v = bpy.nothing.nowhere.nohow(1,2,3,"hi", True, {'dict-test':1}, key="test" )
>bpy.new.func(v.x)
>
>
>this gets converted into a simple string:
>bpy.ops;bpy.data.objects;var0 = 
>bpy.nothing.nowhere.nohow(1,2,3,"hi",True,{'dict-test': 1},key="test",);var1 = 
>bpy.new.func(var0.x,);
>
>
>
>
>While we wait for the scriptlinks replacement, if you need Blender2.5 to talk to 
>another process, the only way i have found is to start it from the command line, 
>setting it into playback mode, and on the redraw event listen to the pipe.  See 
>below.
>
>
>import os,sys, bpy, select
>bpy.ops.screen.animation_play('EXEC_DEFAULT')
>
>
>def draw_callback( area, region ):
>rlist,wlist,xlist = select.select( [sys.stdin], [], [], 0.001 )
>if rlist:
>data = rlist[0].readline()
>print( '>>', len(data) )
>exec( data )
>for area in bpy.context.window.screen.areas:
>print(area.type)
>if area.type == 'VIEW_3D':
>area.tag_redraw()
>for reg in area.regions:
>print( '\tregion: ', reg.type )
>if reg.type == 'WINDOW':
>print( 'adding callback' )
>reg.callback_add(draw_callback, (area,reg), 'POST_PIXEL')
>
>
>
>
>
>On Wed, Jul 21, 2010 at 2:57 AM, Stuart Axon <stuaxo2 at yahoo.com> wrote:
>
>Something like celery might be a way of exporting the api to another python 
>server.
>>
>> S++
>>
>>
>>
>>>
>>>From: Goat Man <goatman.py at gmail.com>
>>>To: Blender Foundation Python list <bf-python at blender.org>
>>>Sent: Tue, July 20, 2010 2:11:49 AM
>>>Subject: [Bf-python] Embedding Blender - XEmbed  protocol
>>>
>>>
>>>I didn't realize Blender can be embedded in a PyGTK window using gtk.Socket.
>>>Its an ugly hack to use the command line "xwininfo" to get the xid, it would be 
>>>better if Blender printed on the command line its windowID or was available in 
>>>the python API.
>>>This demo works most of the time, if the window loses focus then mouse clicking 
>>>stops working, but keyboard and the mouse wheel seems to always work.
>>>
>>>
>>>http://pastebin.com/vYtJmmAC
>>>
>>>
>>>To make this useful we need a way to run a python loop in blender that talks on 
>>>a socket or pipe to the parent process running pygtk.
>>
>>_______________________________________________
>>Bf-python mailing list
>>Bf-python at blender.org
>>http://lists.blender.org/mailman/listinfo/bf-python
>>
>>
>


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20100722/d69a73ed/attachment.html>


More information about the Bf-python mailing list