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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2011   #1
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.
Thanks!
 
Old 02 February 2011   #2
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
 
Old 02 February 2011   #3
Thank you!!
really saves my day!
 
Old 02 February 2011   #4
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 01:51 AM.


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