2017-03-23 46 views
0

Cheers, 我正在寫一個工具,該工具應該獲取具有特定前綴的所有屬性並將它們保存到數組中。Maya MEL將listAttr存入數組

當我使用它自己的listAttr它給了我這樣的事情: // Result: message caching isHistoricallyInteresting nodeState...

我的問題:我想用一個特定的前綴屬性的列表保存到一個數組

梅爾代碼:

string $currentSelection[] = `ls -sl`; 
string $currentAttributes[];    
$currentShapeNode = `ls -shapes -dag -sl $currentSelection`; 
string $currentAttributes[] = `listAttr -ct "ai*"`; 
print $currentAttributes; 

$currentAttributes列表保持爲空。我無法弄清楚我做錯了什麼。

回答

1

您可能與類別和字符串混淆。如果您在doc

ct - >中只顯示屬於給定類別的屬性。類別字符串可以是正則表達式。

st - >僅列出與其他標準匹配的屬性並與從此標誌傳遞的字符串匹配。字符串可以是正則表達式。

所以你的情況,你可能尋找ST

這工作

string $currentSelection[] = `ls -sl`; 
string $currentAttributes[];    
$currentShapeNode = `ls -shapes -dag -sl $currentSelection`; 
string $currentAttributes[] = `listAttr -st "ai*"`; 
print $currentAttributes; 
+0

謝謝你的工作! –