In Maya, I have a list of constraints gathered by the following code. I want to iterate the constraints and query the targets for each of them:
cons = ls(type='constraint')
for con in cons:
targets = constraint(query=True, targetList=True)
The problem, there is no general constraint
command for manipulating all constraints. Instead, each constraint has its own unique MEL command associated with it.
Is there any way to query the targets on a constraint without having to type check each constraint and tediously run its respective MEL command?
listConnections on the .target attr
the cleanup in mel:
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" );
}