Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    OSC Plugin or simple Xpresso Script

    General Talk
    3
    4
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      geese780
      last edited by

      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!

      Cheers!

      MattG

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        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 python.org 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.

        Cheers
        zipit

        [1] https://pypi.org/search/?q="Open+Sound+Control"&o=

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • M
          m_adam
          last edited by m_adam

          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?.

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • G
            geese780
            last edited by

            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!

            Cheers!

            MattG

            1 Reply Last reply Reply Quote 1
            • First post
              Last post