PDA

View Full Version : A weird problem with mel


theknoppix
06-10-2012, 10:26 PM
Hello guys,

I have a mel code that perfectly runs and does its job. no errors or something.

But when I put it in a procedure, it gives undeclared variable errors.


proc $ToVerts() {

string $selVerts[] = `ls -sl -fl`;

string $cl[] = `newCluster " -relative -envelope 1"`;
select -cl;
string $jnt = `joint`;

string $ptCnsJnt[] = `pointConstraint $cl $jnt`;
string $findPtCns[] = `listRelatives -type pointConstraint $jnt`;

float $jointX = `getAttr ($jnt + ".translateX")`;
float $jointY = `getAttr ($jnt + ".translateY")`;
float $jointZ = `getAttr ($jnt + ".translateZ")`;

select $findPtCns[0] $cl[0] $jnt; doDelete;

string $num[];
$numoftokens = `tokenize $selVerts[0] "." $num`;

xform -ws -piv $jointX $jointY $jointZ $num[0];

select -cl;

for ($each in string $selVerts)
{
select -add $each;
}

}


its the $selVerts variable on tokenize row. It says its undeclared.
and the same in for loop. and also $each.

When I delete procedure name and brackets, there's no problem.

I don't know what I'm missing. Thank you in advance.

shcmack
06-28-2012, 12:07 PM
You have to temove the $ at the procedure, and the "string" when defining the loop :)

proc toVerts() {

string $selVerts[] = `ls -sl -fl`;

string $cl[] = `newCluster " -relative -envelope 1"`;
select -cl;
string $jnt = `joint`;

string $ptCnsJnt[] = `pointConstraint $cl $jnt`;
string $findPtCns[] = `listRelatives -type pointConstraint $jnt`;

float $jointX = `getAttr ($jnt + ".translateX")`;
float $jointY = `getAttr ($jnt + ".translateY")`;
float $jointZ = `getAttr ($jnt + ".translateZ")`;

select $findPtCns[0] $cl[0] $jnt; doDelete;

string $num[];
$numoftokens = `tokenize $selVerts[0] "." $num`;

xform -ws -piv $jointX $jointY $jointZ $num[0];

select -cl;

for($each in $selVerts)
{
select -add $each;
}
}

CGTalk Moderation
06-28-2012, 12:07 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.