SimplyMaya Forums

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

Home / forum / Animation / Mel Scripts & Programming / error: it is an undeclared variable, but...I've declared!
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 06-11-2006, 07:26 AM   #1
laiamulet
Registered User
 
Join Date: Oct 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Question error: it is an undeclared variable, but...I've declared!

I have the main procedure called shoppingMall ().

In this procedure I've defined the position of the boxes in world coordinates and after I call another procedure called getDistanceToClosestUV($xBase, $yBase, $zBase) that takes into account the coordenates of my boxes.

In getDistanceToClosestUV() procedure I've translated the coordenates of a nurbs surface in world coordinates as well and after I calculate the minimum distance from the coordinates of the nurbs surface to the coordinates of the boxes.

I have that $ac = getDistanceToClosestUV() and this procedure is returning me a variable that is the minimum distance
return $deltaY;

I have to use the $ac to play with some rules, and the program is telling me that $ac is an undeclared variable, when I'm calling other procedures that are depending on this variable.

I don't understand why!!

I'll send you the 2 main procedures: shoppingMall() and getDistanceToClosestUV() and I hope someone can help me,...

Thank you!
Attached Files
File Type: mel getdistancetoclosestuv.mel (2.0 KB, 26 views)
laiamulet is offline   Reply With Quote
Old 06-11-2006, 07:28 AM   #2
laiamulet
Registered User
 
Join Date: Oct 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

and,.. this is the shoppingMall ()
Attached Files
File Type: mel shoppingmall.mel (1.6 KB, 23 views)
laiamulet is offline   Reply With Quote
Old 06-11-2006, 12:51 PM   #3
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

well I'm not 100% sure because I can't run the scripts because there are some other procs missing (is there any reason why you have them as two separate scripts? couldn't it just be one script with the two procs in it?)

I've noticed that if $deltaY may not get set at all because if this:

if ($dist < $minDistance)

check fails then you will return an undefined $deltaY. You need initialise it to some value, even if it's 0.

It may have something to do with that.


On line 26 of that script aswell you call the name "accessibilty". If you plan on using this script again with other object etc then you should be passing that in as a paramter rather than hard coding it.

e.g.

global proc string myProc()
{
return `getAttr "myObject.tx"`;
}


this is better because you can use it on any object
global proc string myProc(string $myObject)
{
return `getAttr ($myObject + ".tx")`;
}



A
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan 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.