PDA

View Full Version : Set Driven Key


donvlatko
01-05-2008, 06:14 PM
I wish to copy set driven keys from one node to another, does anyone know is there a script out there that do that?

many thanks

nilslerin
01-06-2008, 01:59 PM
Hi donvlatko

Perhaps this scripts will suite your needs:

global proc copyInputConnections()
{
string $sel[] = `ls -sl`;
if(size($sel) != 2) error "Select object that has the input connections, shift-select object that should get the same connections";

string $source = $sel[0];
string $destination = $sel[1];
string $inputs[] = `listConnections -d off -s on -p true -c true $sel[0]`;

/*Inputs[] looks like this
[0]: node.attribute 1 that is connected
[1]: node.attribute that is source of node.attribute 1
[2]: node.attribute 2 that is connected
[3]: node.attribute that is source of node.attribute 2
*/

for($i = 0 ; $i<size($inputs) ; $i+= 2)
{
string $sourceAttr = $inputs[$i+1];

string $buffer[];
tokenize($inputs[$i] , "." , $buffer);
string $destinationAttr = ($destination+"."+$buffer[size($buffer)-1]);
connectAttr -f $sourceAttr $destinationAttr;
}
print ("Copied incoming connections from "+$source+" to "+$destination+"\n");
}
copyInputConnections();


It will copy all incoming connections from one object to another. So if you have setup a relationship with SDKs between two nodes called node1 and node2 and you want the same relationship between node1 and node3, select node2 and node3 and run the script.

It won't duplicate the SDK setup, it will use the same setup but the will work just as good depending on what you need and it's easier to accomplish.

You don't happend to be working with a guy called Dejan, do you?

Regards,
Nils

CGTalk Moderation
01-06-2008, 01:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.