Form and Space

creating CG 3D since 2001

  • Connect @
  • Linked in
  • Vimeo
  • Twitter
dupllicate and match

Maya: Duplicate and Match Transforms

Matthew | September 7, 2012

No Comments

Here’s a duplicate and match transforms script. Right at the end of class today someone was asking for a way to replace their stack of cups with a newly textured cup. I came up with this. He’ll still need to delete or hide the old cups, but this will match the cups transforms and preserve the inputs for each cup.

Note: there are far better methods I’ve created since this was posted. Search for Matching and Neutral pose scripts for more information.

/*
Duplicate and Match Transforms
version .01
Sept. 7, 2012
Author: Matthew L. Stoehr
Source: formandspace.com

Objective:
Duplicate and match object transformations of all selected objects.
Preserves inputs for duplicate objects.

How to use:
Select all objects to match first, select object to duplicate last.
Last object selected is duplicated.
Run script.
*/
_duplicateAndTransform();

proc _duplicateAndTransform(){
string $c[] = `ls -sl`;
int $s = size($c);
int $i = 0;

for ($node in $c){
 
    if($i<$s-1){
        select -r $c[$i];
        vector $vt = `xform -q -ws -t`;
        vector $vr = `xform -q -ws -ro`;
        vector $vs = `xform -q -s`;
           
        select -r $c[$s-1];
        duplicate -un;
        xform -ws -t ($vt.x) ($vt.y) ($vt.z);
        xform -ws -ro ($vr.x) ($vr.y) ($vr.z);
        xform -s ($vs.x) ($vs.y) ($vs.z);
    }
    
    $i++;
}

select -r $c;
}

Leave a Reply

Twitter

Subscribers

    396