Wednesday, June 5, 2013

Mirror Object Tool

So if you you use maya like me I am sure you have used duplicate special at one time or another. while it is a really nice and robust tool 9 times out of 10 I am just duplicating across an axis. So I just made a simpler and faster tool for doing just that. clicking instead of typing -1 will shave off a few seconds while working so I am pleased with it.

The Original idea for the tool I did not come up with I saw some one else have the tool on there blog and I though it would be a good excersie in making a simple mel tool.  http://ttrentlyta.blogspot.com/2011/10/mel-mirror-on-pivot-tool.html

So Here is my version free to use.





/*          *** Mirror Object Tool v 1.0.0 ***
     The tool is very simple it makes a duplicate or instance of
 the object you has selected over the pivot point in the
 "x", "y", or "z" Axis.      */
 
 // checks if there is a window with this ID in memory and if so delets it. also ' != `
 if (`window -exists M_Window`) { deleteUI -window M_Window; }

window -title "Mirror Object Tool" -widthHeight 300 100 M_Window;

formLayout -numberOfDivisions 50 myForm;
    radioButtonGrp
        -numberOfRadioButtons 3
        -label "select type"
        -labelArray3 "x" "y" "z"
        -select 1
    D_Btn;
    button -label "Duplicate object" -command "duplAxis()" myBtn1;
    button -label "Instance object" -command "instAxis()" myBtn2;
 
    formLayout -edit
     -attachForm D_Btn "top" 10
     -attachForm D_Btn "left" -50
     -attachForm myBtn1 "bottom" 10
     -attachForm myBtn1 "left" 10
     -attachForm myBtn2 "bottom" 10
     -attachForm myBtn2 "left" 100
myForm;
showWindow M_Window;
   
     proc duplAxis() {
     if (`radioButtonGrp -q -select D_Btn` == 1) { duplicate -rr; scale -r -1 1 1; }
     if (`radioButtonGrp -q -select D_Btn` == 2) { duplicate -rr; scale -r 1 -1 1; }
     if (`radioButtonGrp -q -select D_Btn` == 3) { duplicate -rr; scale -r 1 1 -1; }
}

 proc instAxis() {
     if (`radioButtonGrp -q -select D_Btn` == 1) { instance; scale -r -1 1 1; }
     if (`radioButtonGrp -q -select D_Btn` == 2) { instance; scale -r 1 -1 1; }
     if (`radioButtonGrp -q -select D_Btn` == 3) { instance; scale -r 1 1 -1; }
}

No comments:

Post a Comment