[問題]MEL

各Maya用戶可在這裡交流問題和分享制作經驗

版主: h2o, stantang

[問題]MEL

文章~高燈星拖~ » 15日 10月 2004年, 19:52

proc AddLocator(){
string $nodes[] = `ls -selection`;
float $tX;
float $tY;
float $tZ;

for ( $node in $nodes ){
$tX = `getAttr $node.translateX`;
$tY = `getAttr $node.translateY`;
$tZ = `getAttr $node.translateZ`;
}
}

當我SELECTED ojbect 多過一件時,
點解getAttr $node.translateX return float[] but not float?

i print $node out is one object from selected object, but the getAttr $node.translateX return all the translateX of selected objects in a float array. WHY?
~高燈星拖~
討論區新秀
討論區新秀
 
文章: 24
註冊時間: 2日 7月 2004年, 21:54

Share On:

Share on Facebook Facebook Share on Twitter Twitter

文章vectoreffect » 15日 10月 2004年, 21:46

`ls -selection`will return a string array. Therefore, you need to create a float array to contain the translation data.

may be you could change it as follow:

proc AddLocator(){
string $nodes[] = `ls -selection`;
float $tX[];
float $tY[];
float $tZ[];

int $i_count = size($nodes);

for($i=0;$i<=($i_count-1);$i++){
$tX[$i] = `getAttr ($nodes[$i] + ".translateX")`;
$tY[$i] = `getAttr ($nodes[$i] + ".translateY")`;
$tZ[$i] = `getAttr ($nodes[$i] + ".translateZ")`;
}
}
頭像
vectoreffect
討論區主持
討論區主持
 
文章: 249
註冊時間: 13日 6月 2002年, 18:13
來自: HK

文章~高燈星拖~ » 15日 10月 2004年, 23:08

THX. 解決了.

三句改為:

$tX = `getAttr ($node +".translateX")`;
$tY = `getAttr ($node +".translateY")`;
$tZ = `getAttr ($node +".translateZ")`;

THX~! :lol:
~高燈星拖~
討論區新秀
討論區新秀
 
文章: 24
註冊時間: 2日 7月 2004年, 21:54


回到 Autodesk Maya

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 5 位訪客

cron