Skip to content

Instantly share code, notes, and snippets.

@baku89
Last active November 14, 2017 18:46
Show Gist options
  • Save baku89/7e2b381bbeac77ba295f to your computer and use it in GitHub Desktop.
Save baku89/7e2b381bbeac77ba295f to your computer and use it in GitHub Desktop.
OSC with C4D
# Dependencies
# pyOSC: https://pypi.python.org/pypi/pyOSC
# SimpleOSC: http://www.ixi-audio.net/content/body_backyard_python.html
# SimpleOSC is wrapper of pyOSC indeed. So this code might be able to be written much briefly.
import c4d
import SimpleOSC as osc
from OSC import OSCClient, OSCMessage
oscToNW = None
focalLength = 17
def onFrameChanged(addr, tags, data, source):
global oscToNW, focalLength, imaiFocal, cpFocal
# sync document time with received timecode
time = c4d.BaseTime(data[0], 24)
doc.SetTime(time)
# send back focal length
obj = op.GetObject()
reader = obj[c4d.ID_USERDATA,9]
focalLength = reader[c4d.ID_USERDATA,13]
osc.initOSCClient(port=1299)
osc.sendOSCMsg("/focallength", [focalLength])
def main():
global focalLength, imaiFocal, cpFocal
osc.server == 0
if osc.server == 0:
# listen
osc.initOSCServer(port=1240)
osc.startOSCServer()
osc.setOSCHandler(address='/frame', hd=onFrameChanged)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment