SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / undeclared variable
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 04-03-2006, 10:52 PM   #1
Falott
Registered User
 
Falott's Avatar
 
Join Date: Jan 2005
Location: vienna
Posts: 1,095
Thanks: 3
Thanked 20 Times in 18 Posts
Default undeclared variable

Im 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 its 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.
__________________
everything starts and ends in the right place at the right time.
Falott is offline   Reply With Quote
Old 04-03-2006, 11:30 PM   #2
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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]" );
}
__________________
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
skywola is offline   Reply With Quote
Old 04-03-2006, 11:35 PM   #3
skywola
Registered User
 
skywola's Avatar
 
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
__________________
"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
skywola is offline   Reply With Quote
Old 05-03-2006, 08:36 AM   #4
Falott
Registered User
 
Falott's Avatar
 
Join Date: Jan 2005
Location: vienna
Posts: 1,095
Thanks: 3
Thanked 20 Times in 18 Posts
Default

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. its funny you mention this, cause I moved them around in every place to find a good position for the eye. Ill use your method from now on.

kind regards!
__________________
everything starts and ends in the right place at the right time.
Falott is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

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

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.