PDA

View Full Version : Problem with using`$variable` i procedure!?


Nenox
10-20-2005, 02:42 PM
Hi. I have a small problem!

I want to make an array that contains the names of objects, whose .message attribute is connected to a multiMessageAttribute. These names MUST be full path names(long), since multiple nodes in the scene have the same name.

I can do this with the following code and that works just fine:

string $charName = "biped_charNode.bindJointsMM";
string $listConnections = "ls -l `listConnections -destination false -source true $charName`";
string $ctrlJointsName[] = `eval $listConnections`;

The problem comes when want to use the code inside a global proc eg:

global proc skListConnections(string $charName){

string $listConnections = "ls -l `listConnections -destination false -source true $charName`";
string $ctrlJointsName[] = `eval $listConnections`;
}

This does not work! I get the error: $charNAme is an undefined variable..

It does however work, if I allready defined $charName in the maya script editor, prior to running the proc. (Outside the proc). But I need to call the proc from another proc, so this is not an option. :-)

Any surgestions??

:-) Sune

NolanSW
10-20-2005, 03:44 PM
slight mod

global proc skListConnections(string $charName){

string $listConnections = "ls -l `listConnections -destination false -source true " + $charName + "`";
string $ctrlJointsName[] = `eval $listConnections`;
}


The variable has to be outside the qoutes.

Nenox
10-20-2005, 04:08 PM
Nice.

That was a little too obvious.. :-|

The actual script line now reads:

string $listConnections = "ls -l `listConnections -destination false -source true " + $charName + "_characterNode.ctrlSkeleton`";

Thanks a lot!

NolanSW
10-20-2005, 11:20 PM
Sure thing.:thumbsup:

CGTalk Moderation
10-20-2005, 11:20 PM
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.