i have been successful making a bridge between two blenders , or 1 cpython 3.2 
and blender , or 1 cpython 2.7 and blender or pypy 1.9 and blender . Its part 
of my project Ephestos, a new blender gui API and a visual coding enviroment in 
pure python

you can see  my client and server here 

https://github.com/kilon/Ephestos/tree/master/proteas 


my server is locked waiting for reply, but that is to be fixed by putting it in 
its own process with the multithreading module , its still WIP but via my tests 
calling blender python function seems to work ok

the goal is not only to make any blender talk to each other but also for any 
language able to use blender python and blender python to use any programming 
language and any library there are available for that language. 

I am using the XMLRPC protocol, but its basically using sockets  




________________________________
 From: Kabir Soorya <[email protected]>
To: [email protected] 
Sent: Thursday, 5 July 2012, 6:37
Subject: [Bf-python] Using a Modal Operator and Nonblocking Sockets to Control 
Blender from an External Python Shell
 

Hi,

I'm trying to find a good way to control Blender from an external Python shell. 
I've spent a lot of time looking at past attempts and see that most haven't 
gone anywhere, as Blender's architecture seems to make this difficult. I tried 
to just have Python's InteractiveInterpreter class fed from a socket, but 
unfortunately Blender locks up completely while listening on the socket -- so 
it's not even able to come back into focus when I Alt-Tab to it. That's not 
really ideal, and so after reading the docs, it seems like the right way to do 
this is to have a modal operator on an event timer repeatedly grab input from a 
nonblocking socket, and feed *that* into InteractiveInterpreter. Unfortunately, 
the only code I've been able to cobble together for event timers seems to make 
blender unresponsive, and cause it to crash horribly. I've attached the code 
below, if anyone knows what's going on -- or has a better way to connect 
Blender to an external Python, I'd
 love to hear your thoughts. 


import bpy
>
>
>class ModalOperator(bpy.types.Operator):
>    '''Operator which runs its self from a timer.'''
>    bl_idname = "wm.modal_operator"
>    bl_label = "Vertex Operator"
>
>
>    _timer = None
>
>
>    def modal(self, context, event):
>        print(event.type)
>        if event.type == 'ESC':
>            print("FINISHED")
>            context.window_manager.event_timer_remove(self._timer)
>            return {'FINISHED'}
>    
>        if event.type == 'TIMER':
>            self.execute(context)
>            return {'RUNNING_MODAL'}
>
>
>    def execute(self, context):
>        print("EXC")
>        bpy.ops.object.mode_set(mode='EDIT')
>        context.window_manager.modal_handler_add(self)
>        self._timer = context.window_manager.event_timer_add(0.1, 
>context.window)
>bpy.utils.register_class(ModalOperator)
>bpy.ops.wm.modal_operator('INVOKE_DEFAULT')

_______________________________________________
Bf-python mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-python
_______________________________________________
Bf-python mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-python

Reply via email to