Hi I’m wanting to send a mel string message to a custom string attribute (“myData”) that i’ve set up on a locator in maya from processing sketch.
I’m getting the error
// Error: Line 1.36: Syntax error //
// Error: setAttr -type string locator1.myData “888”; //
Maybe somebody can set me straight on the correct syntax because theres something wrong in.
String message = ("setAttr -type string locator1.myData " + '"' + $w + '"');
just to clarify i want “888” (including the “”) in the attribute.
for reference heres the maya script editor output if doing it directly on the attribute in maya
setAttr -type "string" locator1.myData "\"888\"";
i’ve tried various variations with the \ and " and quotes around and not around the “string” but can’t get it to work.
Heres the processing sketch
// this app sends data from Processing to string attribute in Maya
//import the .net library
import processing.net.*;
//instantiate a Client instance
Client mayaClient;
//variables
String $w = "888";
// mel script string message to set value of string of attribute "myData" on locator1
String message = ("setAttr -type string locator1.myData " + '"' + $w + '"');
void setup()
{
// this = parent; a wrapper class; localhost = same computer; 6004 = port
mayaClient = new Client(this, "127.0.0.1", 6004);
frameRate(25);
}
void draw()
{
mayaClient.write(message);
}
for those who want to follow along you will need to open a port within maya.
open command port in maya
commandPort -name "127.0.0.1:6004"
close command port in maya
commandPort -name "127.0.0.1:6004" -cl
Cheers guys
Luke
