View Full Version : script command will not execute properly=/

02 February 2011, 03:50 PM
Hi all!
I have this script I'm writing which is used to align objects/components.
global proc dag_alignMain(string $posNeg, string $axis)

So when running the command it should say:
dag_alignMain "-" "x"

However when adding this to a button in the UI i need to use the command flag as so:
-c "align - x"
But now it won't execute properly and I think I can see why. Is it because of the minus sign I use as a string variable and Maya doesn't understand this? What is the correct way of writing this?

I guess I could switch the plus and minus sign to just "pos" and "neg" but I rather would like to understand the problem and how to solve it.

02 February 2011, 04:06 PM
when you pass alpha-numeric strings in MEL you don't need to explicitly denote them as strings using "", compare:

someFunction newName 1 pCube1;
// and:
someFunction "newName" 1 "pCube1";
Both of these are essentially identical and this is why we are all allowed to do stuff like this:
loft -d 1 curve1 curve2 curve3;
delete pCube1;
window -e -wh 100 100 myWindow;
// rather than:
loft -d 1 "curve1" "curve2" "curve3";
// etc..
However, once your string is not an obvious alpha-numeric, or has any ambiguity whether it is a string or not (i.e.: 10 or -) you MUST put it in "double-quotes".
When you must do this INSIDE another literal string you have to escape them, which gets quite messy...
button -l "Align -X" -c "dag_alignMain \"-\" \"x\"";:nathaN

02 February 2011, 04:34 PM
Thank you!!
really saves my day!

CGTalk Moderation
02 February 2011, 04:34 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.