CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 06-10-2012, 09:26 PM   #1
theknoppix
New Member
portfolio
serhat
Eskişehir, Algeria
 
Join Date: Mar 2010
Posts: 2
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.


Code:
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.
 
Old 06-28-2012, 11:07 AM   #2
shcmack
Frequenter
portfolio
Jørn Paulsen
TD/Animator
Norway
 
Join Date: Jan 2004
Posts: 167
You have to temove the $ at the procedure, and the "string" when defining the loop

Code:
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; } }
 
Old 06-28-2012, 11:07 AM   #3
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:28 PM.


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