6
$\begingroup$

For a project I need to drive shape keys with data received via a network connection. In my setup I receive input form a TouchOSC app running on an iPad into PureData on a Mac. The input data then is processed and sent out over UDP to 127.0.0.1:13001.

That's all working fine but now I need Blender to receive the packets, evaluate them and use the values to drive properties on objects. In my case I need to drive the value property of shape keys.

Is this possible and if so, how can I approach this the best way?

$\endgroup$

1 Answer 1

8
$\begingroup$

The basic idea is to open a socket, poll the data and apply the received values to the shape keys:

import socket

# open network socket
port = 13001
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("127.0.0.1", port))
print "waiting on port:", port

# poll data (could use a timer)
data, addr = s.recvfrom(1024) 
print data
# set float value from data
# value convert from data
bpy.context.object.data.shape_keys.key_blocks['Key 1'].value = float(value)

Related:

$\endgroup$
2
  • $\begingroup$ Brilliant, many thanks for your answer. I thought it would be more complex but this works great. $\endgroup$
    – wout
    Apr 2, 2015 at 7:53
  • $\begingroup$ How would this look on a time operator it crashes blender when I run it $\endgroup$
    – Ymmanuel
    Jul 7, 2017 at 23:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .