1 頁 (共 1 頁)

mel script 一問 : 有關get vertex name的問題

文章發表於 : 25日 3月 2007年, 01:44
web_sdas
有mel 問題如下:

以下是我的mel:

string $vpt[] = `ls -sl`;
int $i;
int $s=size($vpt);
print ("\n\nsize : "+$s+"\n");
for( $i=0 ; $i<$s ; $i++ ){
print ($vpt[$i]+"\n");
}

結果:

size : 4
pPlane1.vtx[52]
pPlane1.vtx[62:63]
pPlane1.vtx[72]
pPlane1.vtx[83]

若我想結果如下, 可以怎寫呢?

size : 5
pPlane1.vtx[52]
pPlane1.vtx[62]
pPlane1.vtx[63]
pPlane1.vtx[72]
pPlane1.vtx[83]

請幫忙, 在此先謝過, THANK YOU!!

P.S. 其實最主要想知怎樣可以解決, 用`ls -sl`選vertex,
當vertex array 排列是順序時便會當一個選項處理, 這個可以怎解決呢 :oops: :oops:

文章發表於 : 26日 3月 2007年, 10:54
stantang
try to use "ls -sl -fl" instead.

文章發表於 : 26日 3月 2007年, 21:55
web_sdas
原來如此
無試過 -lf 添 :idea:
真的非常感謝!!
:mrgreen: :mrgreen: :mrgreen:

文章發表於 : 28日 3月 2007年, 01:18
web_sdas
... 不過我發現用`ls -sl -fl`的話
它會把我的選項重新排列過, 這個問題有無方法解決呢??
若我真想的個result系我最初的順序...
:cry: :cry:

文章發表於 : 29日 3月 2007年, 00:24
vectoreffect
`ls -sl -fl` won't change your selection order.

文章發表於 : 29日 3月 2007年, 09:29
stantang
web_sdas 寫:... 不過我發現用`ls -sl -fl`的話
它會把我的選項重新排列過, 這個問題有無方法解決呢??
若我真想的個result系我最初的順序...
:cry: :cry:


Yes, it will change your selection order. You will have to save the selection history as a temporary file somewhere in order to keep your selection order. And yes you can do all that with MEL. I will try it out for you when I have sometime.

文章發表於 : 29日 3月 2007年, 22:46
web_sdas
真的太感謝你了 :mrgreen: :mrgreen:
不過, 你的意思是否無command可以"直接"去做?
而要另外backup 個selection去更正返個順序?
吾...原來如此, 在此先謝過, THANK YOU VERY MUCH!! :wink: :wink: :wink:

文章發表於 : 30日 3月 2007年, 10:33
stantang
web_sdas 寫:不過, 你的意思是否無command可以"直接"去做?
而要另外backup 個selection去更正返個順序?


Yes, you're correct. As far as I know, there isn't a command for that. Maya will re-order your selection no matter what. I've try a bit and find out it's actually pretty complex in order to do what I mentioned (saving the selection as a temp file), I think the eaiser way is to retrack the data from the undo stack. Here's what I had right now, not 100% working and you have to run it right after you did your selection.

I will try with the inital method I mentioned but it will take sometime which I may not have it right now... :oops:

代碼: 選擇全部
//Run it right after your selection of vertex//

string $vpa[] = `ls -sl -fl`;
string $vp[];
string $vpt[];
string $b[];
string $us = `undoInfo -q -un`;
int $a = size($vpa);
int $c = 0;

while (`match "select" $us` != "")
{
$us = `undoInfo -q -un`;
if (`match "select" $us` != "")
{
tokenize $us " " $b;
$vp [$c] = $b[2];
$c++;
undo;
}
}
select $vpa;
for ($i = 0; $i < (`size $vp`); $i++)
$vpt [$i] = $vp[(`size $vp` - $i)-1];

print ("\n\nsize : "+$a+"\n");
print $vpt;

文章發表於 : 2日 4月 2007年, 23:13
web_sdas
it works!! Thank You very much!!
one more question,
why we need to check "(`match "select" $us` != "") "again,
i mean we need not to use :

if (`match "select" $us` != "")
{ ... ... }


and then do :

tokenize $us " " $b;
$vp [$c] = $b[2];
$c++;
undo;


directly is ok.
or there are some purposes to do so perhap??? :oops: :oops: :oops:

文章發表於 : 3日 4月 2007年, 17:51
stantang
The purpose of have that in the mel is to limit "track back" to just the selection commands. Try to run the two versions after you created an object, you will see the difference.

文章發表於 : 6日 4月 2007年, 23:29
web_sdas
thank you!! very clear!!
:wink: :wink: :wink: