script command will not execute properly=/

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  02 February 2011
script command will not execute properly=/

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
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\"";
  02 February 2011
Thank you!!
really saves my day!
  02 February 2011
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:08 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.