[Bf-python] Remote bpy for Blender2.5

Goat Man goatman.py at gmail.com
Fri Jul 30 04:11:32 CEST 2010


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

Example:

def pypy_entry_point_test_bpy():
    ## 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 )
        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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20100729/debae33e/attachment.html>


More information about the Bf-python mailing list