Last active
November 14, 2017 18:46
-
-
Save baku89/7e2b381bbeac77ba295f to your computer and use it in GitHub Desktop.
OSC with C4D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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