Problem connecting attributes using MEL


#1

Well, first to all I apologize if I’m posting this in the wrong section of the CGsociety forum, but I don’t find the specific section to post this, so, I decided to post it here…


Well, I’m making my first MEL tool, I’m creating a ribbon spline rig, and my question is about how and where to place the quotation marks when you add the attribute to connect to the object, and the object name is compound by a result of a string and a string (for example ($resultofstring + “Cube_001”) ), so, when Im going to add the attribute to connect, I have to place everything between quote marks, so, the result would see like this “($resultofstring + “Cube_001”).ty” ) and this become in a two quotation marks string, so doesn’t work,

An short example in code version of the problem is this:

//Here we determinate the prefix string
string $prefix = $Ch_Name + “_”;

//Here we create and place the objects
polyCube -n ($prefix + “Cube_01”);
move 2 0 0 ($prefix + “Cube_01”);
polySphere -n ($prefix + “Sphere_01”);
move -2 0 0 ($prefix + “Sphere_01”);

//Here we connect the attributes
connectAttr “($prefix + “Cube_01”).ty” “($prefix + “Sphere_01”).ty”;


So, as you may see, the connection of the attributes (translate Y, in this case) doesn’t work because the extra quotation marks that we have to make to put the attributes, becomes each object in two strings that the code doesn’t recognize.

So, how I have to put the objects in the connectAttr command to get connected properly?

I apreciate your help! I’m a rigger student and this is my first code project in MEL. :slight_smile:


#2

The problem is the syntaxis.

Look here

//Char name
string $Ch_Name = “Tommy”;

//Here we determinate the prefix string
string $prefix = ($Ch_Name + “_”) ;

//Here we create and place the objects
polyCube -n ($prefix + “Cube_01”);
move 2 0 0 ; // is not necessary put the name here because maya has already selected
polySphere -n ($prefix + “Sphere_01”);
move -2 0 0 ;

//Unselection
select -cl ;

//Here we connect the attributes
connectAttr ($prefix + “Cube_01.ty”) ($prefix + “Sphere_01.ty”) ;

Regards


#3

Great! It works! thanks for the help!!