Problem naming deformers in MEL


#1

Hey everyone,

I’m having an issue with what seems like a fairly basic issue but is screwing up my project progress immensely and I’m at wits end. The issue is part of a MEL script I’m creating in connection to a project where I am both trying to advance my rigging knowledge and learn more about MEL. As such I’m still beginner at MEL so bear with me.

Basically I’ve created a script that I’m storing as a shelf button to generate a procedural ribbon deformer from a tutorial I’ve been watching. Each time I press the shelf button I get a window which lets me name and specify the size (number of joints) in the deformer. I’ve gotten the the script to work the first time it is run and it creates the ribbon deformer … but every new one that gets created (that isn’t duplicated) gets stopped at the nonlinear deformer creation step because it’s looking for “twist1Handle” and regardless of whether I rename the original deformer maya always creates a “twist2Handle” or what ever other type of deformer. I want to get around this issue by naming each nonlinear deformer as it is created by using the name flag (-n) as emplified here…



nonLinear -type twist -n ($name + "_twistHandle") -lowBound -1 -highBound 1 -startAngle 0 -endAngle 0 ;



… but for some reason it doesn’t change the name of the deformer. I use the variable $name to specify user input and give a unique name to everything in the script but even if I try to name it something like “ribbon_twistHandle” without parenthesis I have the same problem. I’ve done all sorts of google searches on the issue but haven’t been able to find anything to help me in my plight. Can anyone help give me insight to what I’m doing wrong?


#2

Definitely first error is learning MEL in 2016.

I’d also aim not to try and rename objects in advance for script consistency reasons. To reference created nodes, just use command return values. According to the manual, “non-linear” procedure returns “Deformer driver name, deformer handle transform name.”. Save result in a variable and use in subsequent calls. I’d provide an example but I’m pretty bad at MEL.


#3

sorry for taking so long to reply… had computer issues.

I have learned a little python but I thought since the script editor displays in MEL and it seems most commands and shelf buttons I’ve seen are written in MEL it would be appropriate to get to know more about it than learn maya commands through python.

Well I was going to reply with a new issue but I got it to work by using.


$deformer = `nonLinear -type twist -lowBound -1 -highBound 1 -startAngle 0 -endAngle 0`; 
rename $deformer[1] ($name + "_twistHandle"); 
rename $deformer[0]($name + "_twist_def");

Thanks for the help!