Operate Maya with OSC from vvvv

Operate Maya with OSC from VVVV

Create an OSC reception environment for Maya

Download python script

Download the script from the following URL to accept OSC in Maya

Download OSC.py Download simpleOSC.py

Place the python script in Maya's python folder

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)

Reception preparation on the Maya side

  1. Create a cube (named pCube1)
  2. Run the following source in the script editor
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.

Prepare to send vvvv OSC

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 sendOSC.png

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)

Operate Maya with vvvv

  1. Set the x coordinate of the cube to 0MayaControl01.png
  2. Change the value of vvvv and check the x coordinate of the maya cube![MayaControl02.png](https://qiita-image-store.s3.amazonaws.com/0/111261/00d21bea-a31b-38ff- 2693-86f682c3156f.png)

Recommended Posts

Operate Maya with OSC from vvvv
Operate Filemaker from Python
Operate Kinesis with Python
Operate neutron from Python!
Operate Blender with Python
Operate LXC from Python
Operate Excel with Python (1)
Operate Excel with Python (2)
Operate Excel with Python openpyxl
Operate TwitterBot with Lambda, Python
[Note] Operate MongoDB with Python
Insert from pd.DataFrame with psycopg2
Get clipboard from Maya settings
Operate your website with Python_Webbrowser
[Python] [SQLite3] Operate SQLite with Python (Basic)
ROS course 105 Operate toio with ROS
With skype, notify with skype from python!
Operate Maya from an external Python interpreter using the rpyc module
Operate Firefox with Selenium from python and save the screen capture