PDA

View Full Version : syntax issues


jilkka
03-10-2011, 05:39 AM
I'm going up the wall because I cant find the syntax issues in my script.

this is pretty long, but any help would be great since its due at 1:30PM EST.



global proc 1Eye() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;


sphere -ax 0 0 1 -n "eye1" -r 1;
move -localSpace (1 * $eyeDist) 0 0;
}

global proc 2Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;

sphere -ax 0 0 1 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (1 * $eyeDist) 0 0;
}

global proc 3Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;

sphere -ax 0 0 1 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (2 * $eyeDist) 0 0;
duplicate;
move -localSpace (3 * $eyeDist) 0 0;
}

global proc 4Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;

sphere -ax 0 0 1 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (2 * $eyeDist) 0 0;
duplicate;
move -localSpace (3 * $eyeDist) 0 0;
duplicate;
move -localSpace (4 * $eyeDist) 0 0;
}

global proc 5Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;

sphere -ax 0 0 1 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (2 * $eyeDist) 0 0;
duplicate;
move -localSpace (3 * $eyeDist) 0 0;
duplicate;
move -localSpace (4 * $eyeDist) 0 0;
duplicate;
move -localSpace (5 * $eyeDist) 0 0;
}

global proc 6Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;

sphere -ax 0 0 1 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (2 * $eyeDist) 0 0;
duplicate;
move -localSpace (3 * $eyeDist) 0 0;
duplicate;
move -localSpace (4 * $eyeDist) 0 0;
duplicate;
move -localSpace (5 * $eyeDist) 0 0;
duplicate;
move -localSpace (6 * $eyeDist) 0 0;
}


global proc 7Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;

sphere -ax 1 0 0 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (2 * $eyeDist) 0 0;
duplicate;
move -localSpace (3 * $eyeDist) 0 0;
duplicate;
move -localSpace (4 * $eyeDist) 0 0;
duplicate;
move -localSpace (5 * $eyeDist) 0 0;
duplicate;
move -localSpace (6 * $eyeDist) 0 0;
duplicate;
move -localSpace (7 * $eyeDist) 0 0;
}

global proc 8Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;

sphere -ax 0 0 1 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (2 * $eyeDist) 0 0;
duplicate;
move -localSpace (3 * $eyeDist) 0 0;
duplicate;
move -localSpace (4 * $eyeDist) 0 0;
duplicate;
move -localSpace (5 * $eyeDist) 0 0;
duplicate;
move -localSpace (6 * $eyeDist) 0 0;
duplicate;
move -localSpace (7 * $eyeDist) 0 0;
duplicate;
move -localSpace (8 * $eyeDist) 0 0;
}

global proc 9Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;
float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;
float $eyeDist = `floatSliderGrp -q -v $numberDist`;

sphere -ax 0 0 1 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (2 * $eyeDist) 0 0;
duplicate;
move -localSpace (3 * $eyeDist) 0 0;
duplicate;
move -localSpace (4 * $eyeDist) 0 0;
duplicate;
move -localSpace (5 * $eyeDist) 0 0;
duplicate;
move -localSpace (6 * $eyeDist) 0 0;
duplicate;
move -localSpace (7 * $eyeDist) 0 0;
duplicate;
move -localSpace (8 * $eyeDist) 0 0;
duplicate;
move -localSpace (9 * $eyeDist) 0 0;
}

global proc 10Eyes() {
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
$eyeColor = `colorEditor -query -rgb`;
int $quantEyes = `intSliderGrp -q -v $numberEyes`;

float $eyeRadius = `floatSliderGrp -q -v $numberRadius`;

sphere -ax 0 0 1 -n "eye1" -r $eyeRadius;
duplicate ;
move -localSpace (2 * $eyeDist) 0 0;
duplicate;
move -localSpace (3 * $eyeDist) 0 0;
duplicate;
move -localSpace (4 * $eyeDist) 0 0;
duplicate;
move -localSpace (5 * $eyeDist) 0 0;
duplicate;
move -localSpace (6 * $eyeDist) 0 0;
duplicate;
move -localSpace (7 * $eyeDist) 0 0;
duplicate;
move -localSpace (8 * $eyeDist) 0 0;
duplicate;
move -localSpace (9 * $eyeDist) 0 0;
duplicate;
move -localSpace (10 * $eyeDist) 0 0;
}

//Proc to create the eyes according to the value of the $numberEyes slider global proc createEyes() {
global string $quantEyes;
global string $openColorEditor;
string eyeColor = `colorEditor -q -rgb`;
if ($quantEyes == 1)
{ 1Eye()
}
if ($quantEyes == 2)
{ 2Eyes()
}
if ($quantEyes == 3)
{ 3Eyes()
}
if ($quantEyes == 4)
{ 4Eyes()
}
if ($quantEyes == 5)
{ 5Eyes()
}
if ($quantEyes == 6)
{ 6Eyes()
}
if ($quantEyes == 7)
{ 7Eyes()
}
if ($quantEyes == 8)
{ 8Eyes()
}
if ($quantEyes == 9)
{ 9Eyes()
}
if ($quantEyes == 10)
{ 10Eyes()
}
colorEyes;
}
// Proc to apply eye color
global proc colorEyes() {
shadingNode -asShader phongE;
sets -renderable true -noSurfaceShader true -empty -name phongE1SG;
shadingNode -asTexture ramp;
connectAttr -force ramp1.outColor phongE1.color;
// Color ramp settings
setAttr ramp1.type 1;
setAttr ramp1.interpolation 0;
// Iris
setAttr "ramp1.colorEntryList[0].color" -type double3 0 0 1;
setAttr "ramp1.colorEntryList[0].position" 0.79;

// Iris end
setAttr "ramp1.colorEntryList[1].color" -type double3 0 0 1;
setAttr "ramp1.colorEntryList[1].position" 0.83;

// Pupil
setAttr "ramp1.colorEntryList[2].color" -type double3 0 0 0;
setAttr "ramp1.colorEntryList[2].position" 0.915;
// Ball
setAttr "ramp1.colorEntryList[3].color" -type double3 1 1 1;
setAttr "ramp1.colorEntryList[3].position" 0;

connectAttr -f phongE1.outColor phongE1SG.surfaceShader;
select -all ;
sets -e -forceElement phongE1SG;
}

//Proc to open the color editor
global proc openColorEditor() {
global string $colorResult;
string $colorResult, $Buffer[];
$colorResult = `colorEditor`;
tokenize($colorResult, $Buffer);
if ("1" == $Buffer[3]) {
print ("RGB = " + $Buffer[0] + " " + $Buffer[1] + " " + $Buffer[2] + "\n");
} else {
print ("Editor was dismissed\n");
}
}
// Create UI Window
global proc eyeCreationUtility() {
global string $openColorEditor;
global string $numberEyes;
global string $numberRadius;
global string $numberDist;
global string $createButton;
global string $newSceneButton;
string $eyeCreator = `window -t "Eye Creation Wizard" -mxb false -mnb true`;
scrollLayout scrollLayout;
columnLayout -adjustableColumn true;
frameLayout -label "Select color for iris"
-borderStyle "in";
columnLayout;
$openColorEditor = `button -l "Click to open color editor" -ann "Click to open color editor to select color for the iris" -c openColorEditor`;
setParent ..;
setParent ..;
frameLayout -label "Controls"
-borderStyle "in";
columnLayout;
$numberEyes = `intSliderGrp -l "Number of Eyeballs" -ann "Drag to set number of eyeballs" -min 1 -v 1 -max 10 -field true`;
$numberRadius = `floatSliderGrp -l "Radius of eyeballs" -ann "Drag to set radius of eyeballs" -min 0.5 -max 10 -field true`;
$numberDist = `floatSliderGrp -l "Distance" -ann "Drag to set distance between eyeballs" -min 1 -v 1.0 -max 20 -field true`;
setParent ..;
setParent ..;
frameLayout -label "Buttons"
-borderStyle "in";
rowColumnLayout;
$createButton = `button -l "Create" -ann "Click to parse options and create eyeballs" -c createEyes`;
$newSceneButton = `button -l "New Scene" -ann "Click to make a new scene" -c "file -f -new"`;
$cancelButton = `button -l "Cancel" -ann "Click to cancel" -c "deleteUI $eyeCreator"`;
setParent ..;
setParent ..;
helpLine;
showWindow $eyeCreator;
}


I'm currently getting the following errors, of which I can not figure out a resolution to:


// Error: global proc 1Eye() { //
// Error: Line 1.13: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 6.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 13.6: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 20.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 27.8: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 34.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 43.10: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 50.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 61.9: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 68.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 81.6: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 88.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 103.6: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 111.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 128.7: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 135.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 154.7: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 161.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 182.7: Syntax error //
// Error: int $quantEyes = `intSliderGrp -q -v $numberEyes`;
//
// Error: Line 189.63: "$numberEyes" is an undeclared variable. //
// Error: }
//
// Error: Line 212.7: Syntax error //
// Error: string eyeColor = `colorEditor -q -rgb`;
//
// Error: Line 221.15: Syntax error //
// Error: { 1Eye()
//
// Error: Line 224.3: Syntax error //
// Error: global proc colorEyes() {
//
// Error: Line 258.11: Procedures cannot be nested within each other. //
// Error: global proc openColorEditor() {
//
// Error: Line 292.11: Procedures cannot be nested within each other. //
// Error: global proc eyeCreationUtility() {
//
// Error: Line 306.11: Procedures cannot be nested within each other. //

cgbeige
03-10-2011, 05:50 AM
I'm not on my computer now but maybe it's because your function starts with a number. From the little I know of C, that is a no no

jilkka
03-10-2011, 05:54 AM
That did it!
Thanks a lot!

Now i just have these errors when trying to source this
:

//Proc to create the eyes according to the value of the $numberEyes slider global proc createEyes() {
global string $quantEyes;
global string $openColorEditor;
string $eyeColor = `colorEditor -q -rgb`;
if ($quantEyes == 1)
{ oneEye()
}
if ($quantEyes == 2)
{ twoEyes()
}
if ($quantEyes == 3)
{ threeEyes()
}
if ($quantEyes == 4)
{ fourEyes()
}
if ($quantEyes == 5)
{ fiveEyes()
}
if ($quantEyes == 6)
{ sixEyes()
}
if ($quantEyes == 7)
{ sevenEyes()
}
if ($quantEyes == 8)
{ eightEyes()
}
if ($quantEyes == 9)
{ nineEyes()
}
if ($quantEyes == 10)
{ tenEyes()
}
colorEyes;
}



Errors:


// Error: } //
// Error: Line 9.1: Syntax error //
// Error: //
// Error: Line 40.0: Syntax error //

haggi
03-10-2011, 07:29 AM
Using semicolons at the end of a line helps a lot in mel coding.

jilkka
03-10-2011, 08:17 AM
alright that bit is fixed.

now i have an issue with my ramp settings. I'm getting this error when i hit create:

// Error: line 267: setAttr: Error reading data element number 1: //


this is the color setting code


// Proc to apply eye color global proc colorEyes() {
$eyeColor = `colorEditor -q -rgb`;
shadingNode -asShader phongE;
sets -renderable true -noSurfaceShader true -empty -name phongE1SG;
shadingNode -asTexture ramp;
connectAttr -force ramp1.outColor phongE1.color;
// Color ramp settings
setAttr ramp1.type 1;
setAttr ramp1.interpolation 0;
// Iris
setAttr "ramp1.colorEntryList[0].color" -type double3 $eyeColor;
setAttr "ramp1.colorEntryList[0].position" 0.79;

// Iris end
setAttr "ramp1.colorEntryList[1].color" -type double3 $eyeColor;
setAttr "ramp1.colorEntryList[1].position" 0.83;

// Pupil
setAttr "ramp1.colorEntryList[2].color" -type double3 0 0 0;
setAttr "ramp1.colorEntryList[2].position" 0.915;
// Ball
setAttr "ramp1.colorEntryList[3].color" -type double3 1 1 1;
setAttr "ramp1.colorEntryList[3].position" 0;

connectAttr -f phongE1.outColor phongE1SG.surfaceShader;
select -all ;
sets -e -forceElement phongE1SG;
}

NaughtyNathan
03-10-2011, 10:00 AM
setAttr doesn't accept an array as value input:
setAttr "ramp1.colorEntryList[0].color" -type double3 $eyeColor;
// should be: (-type is not mandatory)
setAttr "ramp1.colorEntryList[0].color" $eyeColor[0] $eyeColor[1] $eyeColor[2];additionaly, do you really want to do stuff like this:
if ($quantEyes == 1) oneEye();
if ($quantEyes == 2) twoEyes();
...
if ($quantEyes == 10) tenEyes();would it not be far simpler and more efficient to do something like this:
eyesProc $quantEyes;:nathaN

jilkka
03-10-2011, 10:27 AM
Awesome! Works like a charm!

Since it's 5AM here on the east coast of the US I am not going to backtrack and simplify the procs.

CGTalk Moderation
03-10-2011, 10:27 AM
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.