Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 1 02-05-2003 , 08:35 PM
Registered User
Join Date: Sep 2002
Location: Philadelphia
Posts: 43

"Object's name is not unique"

Hi everyone! 'been out of touch for a time. I'm fairly new to scripting. I'm trying to create an animation friendly UI window using the textbook "Mel Scripting For Maya Animators" and I have encountered an error returned that simply makes no sense. "Object's name is not unique" for my line 79. How should I debug this (or any other) script. (Sorry if it seems lame. ) TKU!

# 2 03-05-2003 , 01:03 AM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
first post the code here for us to see so that we can understand what you wanna do user added image

then

find line 79 and check if you've made a silly mistake (VERY easy to do with MEL). It sounds like you're trying to rename an object to a name which already exists. Normally maya handles this by adding an incremental number on the end... hmmm post the code or the offending portion and I'll take a look for ya

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 3 03-05-2003 , 04:20 PM
Registered User
Join Date: Sep 2002
Location: Philadelphia
Posts: 43
global proc setkeys() {

string $names[ ] =`ls -sl`;

if ($names[0] != "RootControl") {

string $name;

for ($name in $names) {

setKeyframe ($name + ".tx");

setKeyframe ($name + ".ty");

setKeyframe ($name + ".tz");

}

} else {

setKeyframe RootControl.ty;

setKeyframe RootControl.tz;

}

}

global proc displayFunc(int $dis) {

int $dis;

switch ($dis) {

case 1:

HideJoints;

hide "*_stdin";

select -r skin; showHidden -a; select -d;

break;

case 2:

hide Character_Skin;

select -r "*_stdin";

showHidden -a; select -d;

break;

case 3:

hide Character_Skin;

hide "*_stdin";

ShowJoints;

break;

default:

}

}

global proc SkeletonControls (){

window

-title "Skeleton Controls"

-widthHeight 450 450

SCcontrols;

string $form = `formLayout`;



//Interface text

string $txt1 = `text -label "Right Arm Left Arm"`;

string $txt2 = `text -label "Waist"`;

string $txt3 = `text -label "Right Foot Left Foot"`;

string $txt4 = `text -label "Display"`;

//Create buttons



// Right Arm

string $b1 = `button -label "Arm"

-command "select -r Arm_RCtrl r_Elbow_RCtrl"`;

string $b2 = `button -label "Wrist"

-command "select -r ForeArm_RCtrl"`;

// Left Arm



string $b3 = `button -label "Arm"

-command "select -r l_Arm_LCtrl l_Elbow_LCtrl"`;

string $b4 = `button -label "Wrist"

-command "select -r l_ForeArm_LCtrl"`;

// Waist

string $b5 = `button -label "Waist" -command "select -r LowerBodyCtrl"`;

// Right Foot

string $b6 = `button -label "Foot" -command "select -r Mover_FootR"`;

// Left Foot

string $b7 = `button -label "Foot" -command "select -r Mover_FootL"`;



//Display buttons

string $b8 = `button -label "HiRes"

-command "int $dis = 1;displayFunc($dis)"`;

string $b9 = `button -label "LoRes"

-command "int $dis = 2;displayFunc($dis)"`;

string $b10 = `button -label "Joints"

-command "int $dis = 3;displayFunc($dis)"`;
//Keyframe button
string $KEYframe = `symbolButton -image "setKey.xpm"
-parent $form -command setkeys`;

columnLayout;


// Sliders for SpineCtrl

floatSliderButtonGrp -label "Side" -field true -buttonLabel "Key"

-buttonCommand "select -r SpineCtrl; setKeyframe SpineCtrl.Side"

-minValue -20.0 -maxValue 20.0

-value 0.0 Side;

connectControl Side SpineCtrl.Side;



floatSliderButtonGrp -label "Twist" -field true -buttonLabel "Key"

-buttonCommand "select -r SpineCtrl; setKeyframe SpineCtrl.Twist"

-minValue -20.0 -maxValue 20.0

-value 0.0 Twist;

connectControl Twist SpineCtrl.Twist;



floatSliderButtonGrp -label "Bend" -field true -buttonLabel "Key"

-buttonCommand "select -r SpineCtrl; setKeyframe SpineCtrl.Bend"

-minValue -20.0 -maxValue 20.0

-value 0.0 Bend;

connectControl Bend SpineCtrl.Bend;



// Text layouts



formLayout -edit

-attachForm $txt1 "top" 80

-attachForm $txt1 "left" 100

-attachForm $txt2 "top" 160

-attachForm $txt2 "left" 100

-attachForm $txt3 "top" 220

-attachForm $txt3 "left" 100

-attachForm $txt4 "top" 280

-attachForm $txt4 "left" 100

$form;



//Button layouts

int $bOffsetW = 180;

int $bOffsetH1 = 80;

int $bOffsetH2 = 140;



formLayout -edit

-attachForm $b1 "top" 98

-attachForm $b1 "left" 80



-attachForm $b2 "top" 120

-attachForm $b2 "left" 80



$form;



formLayout -edit

-attachForm $b3 "top" 98

-attachForm $b3 "left" (80 + $bOffsetW)



-attachForm $b4 "top" 120

-attachForm $b4 "left" (80 + $bOffsetW)

$form;



formLayout -edit

-attachForm $b5 "top" (98 + $bOffsetH1)

-attachForm $b5 "left" 80

$form;



formLayout -edit

-attachForm $b6 "top" (98 + $bOffsetH2)

-attachForm $b6 "left" 80

$form;



formLayout -edit

-attachForm $b7 "top" (98 + $bOffsetH2)

-attachForm $b7 "left" (80 + $bOffsetW)

$form;



formLayout -edit

-attachForm $b8 "top" 305

-attachForm $b8 "left" 80

-attachForm $b9 "top" 305

-attachForm $b9 "left" 118

-attachForm $b10 "top" 305

-attachForm $b10 "left" 158
$form;

formLayout -edit
-attachForm $KEYframe "top" 170
-attachForm $KEYframe "left" 360

$form;



showWindow SkeletonControls;

}

# 4 03-05-2003 , 06:22 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
this script worked ok for me....well I managed to execute it with no probs it didnt seem to do anything though.

My question is what's Scontrols? check this line of code:

window

-title "Skeleton Controls"

-widthHeight 450 450

SCcontrols;

string $form = `formLayout`;

it's not a flag I take it?


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 5 03-05-2003 , 07:13 PM
Registered User
Join Date: Sep 2002
Location: Philadelphia
Posts: 43
Thanks for reviewing my script Pure Morning. Funny that you should point out the SCcontrols. Although I did change that to SkeletonControls, and resaved the mel script, when I go to source the script, I get nothing. I am sure that it is in the script path, i.e., placed in the 4.5 script folder, but my feedback still notes problems with the column layout. I get nothing. no window appears and the only return is an error message at that point. I even tried dumbing down the script and nothing appears. When you ran the script, clearly nothing would happen since the flags referencing mover/solvers would not be active in your scene. In effect, what I am hoping for is a mel script that will make sliders for animating a biped. Can you help in that regard? I am working out of a school that doesn't actually offer Maya classes and I am left to my own resources, so to speak. Needless to say, your help is most welcome. ps, I am friends with Heinrich who also posts here. Thanks again!

# 6 03-05-2003 , 07:18 PM
adldesigner's Avatar
Registered User
Join Date: Sep 2002
Location: CCS, Venezuela
Posts: 3,363
Welcome to SimplyMaya Skyzeyez

Even though MEL Scripting is not a part I excel in, you will get help around here from people who do know.

Hope you enjoy your stay around here.

# 7 03-05-2003 , 07:37 PM
Registered User
Join Date: Sep 2002
Location: Philadelphia
Posts: 43
Thanks adldesigner!

# 8 03-05-2003 , 08:03 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Ok i still dont get what "Scontrols" is. If you are putting something in the window command it needs to be preceeded by a flag like you have done with the -title "your title" SControls surely shouldn't be there? can you explain a little better what that does?


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 9 04-05-2003 , 05:45 PM
Registered User
Join Date: Sep 2002
Location: Philadelphia
Posts: 43
Thanks again on looking into this for me Pure Morning. As to the purpose of "SCcontrols," I assumed that the flag was a final reference to the window. I have interpreted the script from that which I took from the textbook "Mel Scripting for Maya Animators."
On your suggestion, I removed it from the string. Nevertheless, when I once again tried to source the script, I got another error message--something about mel line 288 : too many arguments. Expected 1, found 2. I've no idea why that would be. Any suggestions? 'seems peculiar since the script doesn't have that many lines!user added image


Last edited by skyzeyez; 04-05-2003 at 05:55 PM.
# 10 05-05-2003 , 02:28 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
from looking at the MEL command reference I would take off the brackets on these lines and see if that helps.

Oh and you do have 288 lines of code (318 to be exact! check your line numbers!!) user added image

formLayout -edit

-attachForm $b7 "top" 98 + $bOffsetH2

-attachForm $b7 "left" 80 + $bOffsetW

$form;


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 11 08-05-2003 , 06:54 AM
mark_wilkins's Avatar
Registered User
Join Date: Jan 2003
Posts: 161

Answers

Hi!

Well, I wrote MEL Scripting for Maya Animators. Glad you're enjoying it user added image user added image user added image

just kidding.

OK, so here are a few things:

*** First off, leave the parentheses ON when you add 98 and 80 to $bOffsetH2 and $bOffsetW. Otherwise, Maya will try to interpret the + in the addition as a separate argument to formLayout and go nuts.

*** Second, the purpose of the line

window -title "Skeleton Controls" -widthHeight 450 450 SCcontrols;

is to make a window object called SCcontrols. At the end of your script, though, when you call showWindow, you say

showWindow SkeletonControls;

So you're naming the window object SCcontrols when you make it and SkeletonControls when you try to show it. This is why it doesn't do anything -- the latter command should be

showWindow SCcontrols;

*** Finally, as to your original question, all of this code makes a window object with a particular name. Maya will complain if you try to make two window objects with the same name. Probably you ran the script more than once and the second time you started getting the error.

The solution is on page 468 of the book: "If you are getting errors and need to delete the window, type in deleteUI MBcontrols"

So for your script, if you want to run it a second time, you'll need to type

deleteUI SCcontrols;

or

deleteUI SkeletonControls

depending on what you actually choose to name your window.

Hope that helps!!

-- Mark


Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com
# 12 13-05-2003 , 09:34 PM
Registered User
Join Date: Sep 2002
Location: Philadelphia
Posts: 43
Thank you Mark! 'kinda embarassed. Yeah, I really enjoy the book. We are finally starting to see well written books for Maya users.

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off