Solved OSC Plugin or simple Xpresso Script

Hey Everyone,

I was wondering what might be easier to acheive a very "simple" task I'm trying to accomplish. I'm trying to grab a single OSC message from an external program (touchdesigner) and bring it into C4D to control a slider I built for an object. Is utilizing the xpresso tag python script easier or does OSC not exist in that node? Appologies if this is a redundent question, still researching the best I can. Thank you for your time!




welcome to the forum. I assume with OSC you are referring to Open Sound Control (acronyms are usually less obvious and unambiguous than one might think, please resolve them in the future)? Neither the Python standard library nor Cinema4D do natively support OSC, there are however multiple Python packages available that deal with OSC [1].

A XPresso node has in principal the same level of system access like even the most elaborate plugin, but it lacks persistence as all scripting nodes do. That means that a node is being executed and then c4d "forgets" the node until the node has to be executed again, causing you to loose all states, variables, and data which you have not passed out of the node. With some experience you can "hack" your way around this problem by storing your data in the interpreter, but I would not recommend doing it.

Since with OSC you will have to establish a client-server communication, this will most likely be a problem and you will probably need some sort of persistent plugin like a MessageData or CommandData plugin. Also as general point of advice: While Cinema's Python interpreter is as vanilla as it gets, I would recommend experimenting with OSC in a default interpreter. This will remove any uncertainties that might come up when facing unexpected problems that client-server stuff and smaller third party packages can sometimes present.



MAXON SDK Specialist

Hi @geese780 as @zipit zipit already pointed there is nothing build-in to do OSC (sound control I guess) so your best bet is to use an already existing OSC library like python-osc with pip.
For more information about how to use pip to install 3rd party library see 3rd party APIs into pyp/pypv file Note that since R21 it's no more needed to download c4dpy since it's part of the c4d installation.

Now how to implement it in C4D? I assume OSC is based on UDP/TCP so you need to have a server that runs on the background during Cinema 4D life.
As @zipit pointed it, doing it into an xpresso node is really not the way to go since an xpresso node is a GvNode which is a BaseList2D so that means it has a given lifetime see NodeData Management.
The best way is probably through a plugin you can find an example of a background server thread waiting for some information in the next topic How to get mouse drag info from external through Python API?.


Hey Guys!

Thank you very much for the insight! All of this makes sense, it helps me understand a little more about how the node part works! I really appreciate the time on this and thanks again for the help! I hope y'all are doing well!