在Maya中,我有一个由以下代码收集的约束列表。我想迭代约束并查询每个约束的目标:
cons = ls(type='constraint')
for con in cons:
targets = constraint(query=True, targetList=True)
问题是,没有用于操纵所有约束的通用constraint
命令。相反,每个约束都有自己唯一的MEL命令。
有没有办法查询约束上的目标而不必键入检查每个约束并繁琐地运行其各自的MEL命令?
答案 0 :(得分:2)
.target attr
上的listConnections梅尔的清理:
string $cons[] = `ls -type "constraint"`;
for ( $con in $cons ){
string $targetAttrString = ( $con+ ".target" );
string $connections[] = `listConnections $targetAttrString`;
string $connectionsFlattened[] = stringArrayRemoveDuplicates($connections);
for ( $f in $connectionsFlattened )
if ( $f != $con )
print ( $f+ " is a target\n" );
}