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

有關 Effect - Dynamics , Particles , Fluids 等技巧討論

版主: vectoreffect

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

文章web_sdas » 25日 3月 2007年, 01:44

有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:
web_sdas
CGV討論區會員
CGV討論區會員
 
文章: 156
註冊時間: 18日 9月 2004年, 12:48
來自: HK

Share On:

Share on Facebook Facebook Share on Twitter Twitter

文章stantang » 26日 3月 2007年, 10:54

try to use "ls -sl -fl" instead.
dig deep, think deeper
頭像
stantang
討論區主持
討論區主持
 
文章: 1566
註冊時間: 8日 11月 2001年, 08:00
來自: Groom Lake

文章web_sdas » 26日 3月 2007年, 21:55

原來如此
無試過 -lf 添 :idea:
真的非常感謝!!
:mrgreen: :mrgreen: :mrgreen:
web_sdas
CGV討論區會員
CGV討論區會員
 
文章: 156
註冊時間: 18日 9月 2004年, 12:48
來自: HK

文章web_sdas » 28日 3月 2007年, 01:18

... 不過我發現用`ls -sl -fl`的話
它會把我的選項重新排列過, 這個問題有無方法解決呢??
若我真想的個result系我最初的順序...
:cry: :cry:
web_sdas
CGV討論區會員
CGV討論區會員
 
文章: 156
註冊時間: 18日 9月 2004年, 12:48
來自: HK

文章vectoreffect » 29日 3月 2007年, 00:24

`ls -sl -fl` won't change your selection order.
頭像
vectoreffect
討論區主持
討論區主持
 
文章: 249
註冊時間: 13日 6月 2002年, 18:13
來自: HK

文章stantang » 29日 3月 2007年, 09:29

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.
dig deep, think deeper
頭像
stantang
討論區主持
討論區主持
 
文章: 1566
註冊時間: 8日 11月 2001年, 08:00
來自: Groom Lake

文章web_sdas » 29日 3月 2007年, 22:46

真的太感謝你了 :mrgreen: :mrgreen:
不過, 你的意思是否無command可以"直接"去做?
而要另外backup 個selection去更正返個順序?
吾...原來如此, 在此先謝過, THANK YOU VERY MUCH!! :wink: :wink: :wink:
web_sdas
CGV討論區會員
CGV討論區會員
 
文章: 156
註冊時間: 18日 9月 2004年, 12:48
來自: HK

文章stantang » 30日 3月 2007年, 10:33

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;
dig deep, think deeper
頭像
stantang
討論區主持
討論區主持
 
文章: 1566
註冊時間: 8日 11月 2001年, 08:00
來自: Groom Lake

文章web_sdas » 2日 4月 2007年, 23:13

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:
web_sdas
CGV討論區會員
CGV討論區會員
 
文章: 156
註冊時間: 18日 9月 2004年, 12:48
來自: HK

文章stantang » 3日 4月 2007年, 17:51

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.
dig deep, think deeper
頭像
stantang
討論區主持
討論區主持
 
文章: 1566
註冊時間: 8日 11月 2001年, 08:00
來自: Groom Lake

文章web_sdas » 6日 4月 2007年, 23:29

thank you!! very clear!!
:wink: :wink: :wink:
web_sdas
CGV討論區會員
CGV討論區會員
 
文章: 156
註冊時間: 18日 9月 2004年, 12:48
來自: HK


回到 ■ Effects

誰在線上

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