Download the script from the following URL to accept OSC in Maya
Download OSC.py Download simpleOSC.py
Place Osc.py and simpleOSC.py in the following locations (Application installation folder) \ Autodesk \ (Maya version) \ Python \ Lib \ site-packages \ maya
Now you can call simpleOSC methods by writing the following, and you will be able to operate OSC in Maya.
import maya.simpleOSC
maya.simpleOSC.initOSCClient(ip='127.0.0.1', port=11112)
import maya.cmds
import maya.simpleOSC
def moveObj(addr, tags, data, source):
print "%s\n" % data
cmds.setAttr( 'pCube1.translateX', data[0] )
maya.simpleOSC.print_Test()
maya.simpleOSC.initOSCClient(ip='127.0.0.1', port=11112)
maya.simpleOSC.initOSCServer(ip='127.0.0.1', port=11111, mode=0)
maya.simpleOSC.setOSCHandler('/vvvv', moveObj)
maya.simpleOSC.startOSCServer()
#maya.simpleOSC.closeOSC()
You can disconnect by running maya.simpleOSC.closeOSC (). When modifying the Handler, disconnect it once and then connect it again.
The sample code is included when you download vvvv. Open the OSC sample code and refer to the part where the OSC is sent. (Path with vvv.exe) /girlpower/IO/Networking/2_Advanced (OSC) /00_OSC_Examples_1.v4p
Align the port number to send with Maya. (This time, since maya.simpleOSC.initOSCServer is set to port = 11111, set 11111 for vvvv as well) maya.simpleOSC.initOSCServer(ip='127.0.0.1', port=11111, mode=0)
If you want to operate between PCs with different IPs, set the IP as well. (This time, I will operate it on my PC, so I set ip = 127.0.0.1 or localhost)
Recommended Posts