Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   error: it is an undeclared variable, but...I've declared! (https://simplymaya.com/forum/showthread.php?t=23799)

laiamulet 06-11-2006 08:26 AM

error: it is an undeclared variable, but...I've declared!
 
1 Attachment(s)
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!

laiamulet 06-11-2006 08:28 AM

1 Attachment(s)
and,.. this is the shoppingMall ()

Alan 06-11-2006 01:51 PM

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")`;
}


:ninja:
A


All times are GMT. The time now is 04:10 PM.

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