Showing posts with label Mel-Script. Show all posts
Showing posts with label Mel-Script. Show all posts

2007/07/31

Mel Script -- 抓polygon的vertex


int $n[] = `polyEvaluate -vertex pSphere1`;
int $num = $n[0];
vector $pos;

for($i=0; $i < $num; $i++)
{
 $pos = `getAttr pSphere1.vrts[$i]`; //local 座標
 //$pos = 'pointPosition -l pSphere1.vtx[$i]`; 與上行等效
 print($pos);
}

/* 與上述for loop 等效 */
//float $coord[] = `getAttr pSphere1.vrts["*"]`;
//print($coord);


for($i=0; $i < $num; $i++)
{
 $pos = `pointPosition -w pSphere1.vtx[$i]`;
 print($pos);
}

2007/07/22

Mel Script的相關設定檔

1.Maya Mel Script的預設存放處, 意指存在此處的Script會在Maya打開時, 自動載入.
C:\Documents and Settings\用戶名\My Documents\maya\版本號\scripts\

若同時安裝有Maya 8.5則下列位置中的Mel Script, 也會在Maya打開時自動載入.
C:\Documents and Settings\用戶名\My Documents\maya\scripts\

以上只是載入而已, 要執行仍需在指令列打function name (而不是xxx.mel唷!)

此外下面這行Mel Script的指令可以查user script directory.
internalVar -userScriptDir;

2.Maya Environment Variables, 供使用者設定Sript or Plug-in Path.

(1)設定系統變數

(2)C:\Documents and Settings\用戶名\My Documents\maya\版本號\Maya.env
預設是空的檔案。
在Maya.env中加入下面這行, 就可指定Maya打開時自動載入mel script的位置.
MAYA_SCRIPT_PATH = [your own Mel script path]
MAYA_PLUG_IN_PATH = [your own Plug-in path]

(3)設定Maya啟動時的初始動作。
 C:\Documents and Settings\用戶名\My Documents\maya\版本號\scripts\userSetup.mel
預設此mel檔是不存在的。
你可以自行在上述目錄中create 一個userSetup.mel
並鍵入下面的mel script指令。
confirmDialog
-title "welcome!"
-message "Hello World!"
-button "OK"
;
重新打開Maya看看會發生什麼有趣的事...

2007/05/15

Mel 小筆記

help -doc [command name]

setAttr:設定object屬性。

whatIs [command name or Mel script name]:判別該命令是不是Mel Script


字串處理相關命令:
substring
tokenize
size
clear
match
substitute


ls -sl; 取得所有被選取物件的名字串列
filterExpand -sm [Mask number] 只取得特定型別的物件(如Polygon, Nurbs, Particle..)

使用"source"命令可以執行mel文件。例如:
source "c:/crowd.mel";



Mel Studio Pro:
Ctrl+Shift +left click 將Mel Studio加入shelf
Ctrl+Space 語法提示 (跟輸入法切換衝, 不知道怎麼修改hot key)
Ctrl+Shift +del 清除歷史記錄