Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   undeclared variable (https://simplymaya.com/forum/showthread.php?t=20491)

Falott 04-03-2006 11:52 PM

undeclared variable
 
I´m currently reading The MEL Companion. very good lecture! but -

is it possible, since the book was published in 2003 that some of the scripting language has changed? cause not even one of the examples.mel work correctly with maya 7.


global proc generateGrass()

{
//Creation of Poly Cone
string $blades[] = `polyCone -r .04 -h 1 -sx 3 -sy 10 -sz 0 -ax 0 1 0 -tx 1 -ch 0`;

//bring the bottom of the cone to groundlevel
setAttr ($blades[0] + ".translateY") 0.5 ;

}

// till here it´s working ------------

// harden the edges of cone
polySoftEdge
-angle 30
-constructionHistory off
( $blades[0] + ".e[0:59]" )
;


line 22.19: "$blades" is an undeclared variable. //



why is $blades[] in the second place a undeclared variable? and if there is a reasonable say syntax error or something, why is this provided by the book in exactly such way?

would be happy if someone could help me out.

skywola 05-03-2006 12:30 AM

Misplaced bracket - - BTW, I dislike the way most MEL coders position their brackets . . . . This is how I do it . .

global proc generateGrass() {
//Creation of Poly Cone
string $blades[] = `polyCone -r .04 -h 1 -sx 3 -sy 10 -sz 0 -ax 0 1 0 -tx 1 -ch 0`;

//bring the bottom of the cone to groundlevel
setAttr ($blades[0] + ".translateY") 0.5 ;

// harden the edges of cone
polySoftEdge
-angle 30
-constructionHistory off
( $blades[0] + ".e[0:59]" );
}

skywola 05-03-2006 12:35 AM

I have seen some pretty sorry examples of what people call MEL tutorials . . . . some of the clowns that write these obviously never even bother to test their code. Kind of like when you were in school and you find out that the answer in the math book is wrong . . . very frustrating, and certainly not helpful.

There is really not a lot of variation of MEL from one version of Maya to the next. If there is, it is usually only added functionality, and added functionality should not cause problems, unless you run code meant for Maya 7 in Maya 5, then you might run in to some issues.

Falott 05-03-2006 09:36 AM

of course, last code was not part of the statement anymore. but i fear this error was done by me, cause the tutorial adds code gradually and I oversaw the curly bracket.

anyways, thx a lot really!

and for the bracket placing. it´s funny you mention this, cause I moved them around in every place to find a good position for the eye. I´ll use your method from now on.

kind regards!


All times are GMT. The time now is 12:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018