Maya MEL 将 listAttr 保存到数组中

Maya MEL save listAttr into array

干杯, 我正在编写一个工具,该工具应该获取具有特定前缀的所有属性并将它们保存到数组中。

当我单独使用 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列表为空。我不知道我做错了什么。

您可能混淆了类别和字符串。如果你仔细看看文档

ct -> 只显示属于给定类别的属性。类别字符串可以是正则表达式。

st -> 仅列出与其他条件匹配且与从该标志传递的字符串匹配的属性。字符串可以是正则表达式。

所以在你的情况下你可能正在寻找 st

这个有效

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