PDA

View Full Version : "#1" used in mel UI's


tbaypaul
11-22-2006, 07:03 PM
I am browsing the geometryPaint.mel script in the maya install/script/others folder.

they push the DefaultTemplete onto the stack and then seem to parse the command values via this "#1" thingy...

WHAT the blank does #1 mean? It seems a powerful shortcut to getting values??? They seem to tokenize the ui textfield by using it and directly assigning contol values with it??

so ..example from line 165
where all of the variables are global.


textFieldGrp -label "Geometry:"
-text $geom
-cc "tokenize( \"#1\", $geometryGeom )"
geometryName;
textFieldGrp -label "Identifier:"
-text $geometryIdentifier
-cc "$geometryIdentifier = \"#1\""
geometryIdentifier;

...... more controls.....

checkBoxGrp -ncb 3 -l "Control:"
-l1 "X Scale" -v1 $geometryModifyAttr[0]
-cc1 "$geometryModifyAttr[0] = #1"
-l2 "Y Scale" -v2 $geometryModifyAttr[1]
-cc2 "$geometryModifyAttr[1] = #1"
-l3 "Z Scale" -v3 $geometryModifyAttr[2]
-cc3 "$geometryModifyAttr[2] = #1"
control0;

sunit
11-22-2006, 09:30 PM
it's a way to access the current context value. so, for example:

{
window;
columnLayout;
string $sl = `intSlider`;
string $foo = `intField`;
intSlider -e -dc ("intField -e -v #1 "+$foo) $sl;
showWindow;
}

notice how the intfield updates with values from the slider. the #1 simply passes the current context (the slider) value on,

-sunit

tbaypaul
11-23-2006, 12:56 AM
thank you. That is very helpful. I could see what it was doing and knew the script worked, but was confused by something I've not seen before.

Does that have a formal name? So, I can at least sound intelligent about it. I preferred to not call it that #1 thingy. That wouldn't look very professional in my notes.

sparaig
11-23-2006, 01:05 AM
thank you. That is very helpful. I could see what it was doing and knew the script worked, but was confused by something I've not seen before.

Does that have a formal name? So, I can at least sound intelligent about it. I preferred to not call it that #1 thingy. That wouldn't look very professional in my notes.

Maybe " control '#-index'?"

It's documented, but I don't think that they name it anything. They just say use "#+number" or something.

goleafsgo
11-23-2006, 01:26 PM
I don't think there is an official name for it.

From the Maya doc's:

Often the value of the control is needed as a parameter in the command that it issues. To avoid querying the control each time its state changes, its value can be symbolically embedded in the command as the string "#1". When the control changes value then the "#1" will be substituted with the actual value of the control at the time the command is issued. Groups with multiple values use "#2", "#3", etc. for the values of their different components. For example, a float field group with three fields can represent the values of each of those fields in its commands with "#1", "#2", "#3" respectively.

CGTalk Moderation
11-23-2006, 01:26 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.