blender2.5 bpy proxy (remote bpy)

http://pastebin.com/B8PmuDrv

Allows access to bpy.ops and bpy.data from a remote python2 or PyPy interpreter. Implementation uses a pipe, but this can be replaced by a socket for truly remote access. The binding generator works by RNA introspection, and outputs RPython compatible code. Optionally you can write RPython code that will compile to C. This proxy is also useful if you need a python2 interpreter to talk to a python3 interpreter outside of Blender.

Currently a hack is used to make Blender listen on the pipe, using playback and the on_redraw event, hopefully Blender will provide an interface soon for talking on pipes/sockets and forced redraw events.

below is an example:



def pypy_entry_point_test_bpy():
    start = time.time()
    ## init wrapper ##
    bpy_ops = bpy_ops_wrapped()
    bpy_ops_mesh = bpy_ops.mesh()
    bpy_data = bpy_data_wrapped()
    bpy_data_objects = bpy_data.objects()
    ######################

    objs = bpy_data_objects.values()
    for ob in objs:
        debug(str(ob))
        debug( str( ob.location()) )

    names = bpy_data_objects.keys()
    camera = None
    for n in names:
        ob = bpy_data_objects.get( n )
        debug( str(ob) )
        if n == 'Camera':
            camera = ob
            scale = camera.GET_scale()
            debug( 'camera scale: %s' %scale )
            scale[0] = 10.0
            camera.scale( scale )
            break

    i = 0
    while True:
        x = math.sin( radians(i) ) * 1.0
        y = math.cos( radians(i) ) * 1.0
        bpy_ops_mesh.primitive_plane_add( location=(x,y,.0) )
        for ob in objs: ob.location( [x,y,.0] )
        i += 1
        if i == 360: break