A weird problem with mel

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  06 June 2012
A weird problem with mel

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.
 
  06 June 2012
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;
}
}
 
  06 June 2012
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



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
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:59 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.