PDA

View Full Version : Streamlined Symmetry Script


Shon Mitchell
07-15-2010, 08:50 AM
Hi all, got tired of messing around with maya's Duplicate Special and created a script that pretty much streamlines setting up Instanced linear and radial symmetry. just place script in script editor, highlight all and drag to shelf

enjoy!



if(`window -exists "QuickSymm"`)
{
deleteUI "QuickSymm";
}

window QuickSymm;

columnLayout -cat "both" 0 -cal "center" -cw 310;
text -h 50 -align "center" -label "LINEAR";
setParent ..;
rowLayout -numberOfColumns 3 -cw3 100 100 100 -ct3 "both" "both" "both" -cl3 "center" "center" "center";
button -label "X" -command "mirrorcallback 1";
button -label "Y" -command "mirrorcallback 2";
button -label "Z" -command "mirrorcallback 3";

setParent ..;
text -h 50 -align "center" -label "RADIAL";

setParent..;
rowLayout -numberOfColumns 3 -cw3 100 100 100 -ct3 "both" "both" "both" -cl3 "center" "center" "center";
button -label "Radial X" -command "radialcallback 1";
button -label "Radial Y" -command "radialcallback 2";
button -label "Radial Z" -command "radialcallback 3";

setParent ..;
columnLayout -cat "both" 0 -cal "center" -cw 300;
text -h 50 -align "center" -label "Number of Pieces";

setParent ..;
columnLayout -co "both" 125 -cw 300;
intField -w 50 -minValue 3 -value 3 NumSides;


window -edit -wh 310 280 QuickSymm;
showWindow QuickSymm;

global proc mirrorcallback(int $Linear)
{
switch($Linear)
{
case 1:
duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,-1,1,1);

break;
case 2:
duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,-1,1);
break;
case 3:
duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,-1);
break;

default:
break;
}
}

global proc radialcallback(int $MirrorAxis)
{
int $numInstances = `intField -q -value NumSides`;
float $Division = 360 / float ($numInstances);

switch($MirrorAxis)
{
case 1:
duplicatePreset(--$numInstances,0,1,0,0,0,0,0,0,0,0,$Division,0,0,1, 1,1);
break;

case 2:
duplicatePreset(--$numInstances,0,1,0,0,0,0,0,0,0,0,0,$Division,0,1, 1,1);
break;

case 3:
duplicatePreset(--$numInstances,0,1,0,0,0,0,0,0,0,0,0,0,$Division,1, 1,1);
break;

default:
break;
}
};

LMP
08-16-2010, 01:39 AM
sounds cool, I'll try it sometime

A_GAME
09-06-2010, 11:14 AM
It works great! Thanks!

mimic12455
09-10-2010, 10:10 AM
Any particular things we need to know about the script so we can have a better understanding of it? You know, what button does what and what not to do. For some reason when I use it, it only moves between the original and mirrored position instead of making a row

Shon Mitchell
09-10-2010, 12:11 PM
its pretty straight forward, the linear buttons simply create an instance duplicate across the axis of the button you press, X, Y, or Z

Radial Symmetry buttons read in the number tab and make equal distant instanced duplicates in a circular pattern around the chosen axis

it doesn't create instances as a standard duplicate yet, I might add a row and column feature to it later, for the most part it just takes care of instanced Symmetry

Hans Schrijvers
09-10-2010, 09:43 PM
great utility, I approve.

Shon Mitchell
09-13-2010, 08:15 AM
Here's a vid demo of its uses in production workflow

http://www.youtube.com/watch?v=_Sip6ubS-Ng

Gary
09-20-2010, 09:57 PM
I keep on getting a "// Error: Syntax error"

Shon Mitchell
09-21-2010, 06:48 PM
make sure the script you copied starts at the 'if' and ends on the final ';'
i think maybe its not reading the entire script when you try and save it to shelf

Gary
09-22-2010, 08:32 PM
i think i missed a line, it works now.

Doukie
09-23-2010, 10:30 AM
I just wanted to say that this is completely awesome and helpful! Thanks so much Shon!

Shon Mitchell
10-13-2010, 04:24 PM
Small update. I added a singular Instance button that will allow you to create a non mirrored Instance Duplicate.

Next will try and implement an auto row and column feature


if(`window -exists "QuickSymm"`)
{
deleteUI "QuickSymm";
}

window QuickSymm;

columnLayout -cat "both" 0 -cal "center" -cw 310;
button -label "SINGLE" -command "instancecallback";

setParent ..;


columnLayout -cat "both" 0 -cal "center" -cw 310;
text -h 50 -align "center" -label "LINEAR";
setParent ..;
rowLayout -numberOfColumns 3 -cw3 100 100 100 -ct3 "both" "both" "both" -cl3 "center" "center" "center";
button -label "X" -command "mirrorcallback 1";
button -label "Y" -command "mirrorcallback 2";
button -label "Z" -command "mirrorcallback 3";

setParent ..;
text -h 50 -align "center" -label "RADIAL";

setParent..;
rowLayout -numberOfColumns 3 -cw3 100 100 100 -ct3 "both" "both" "both" -cl3 "center" "center" "center";
button -label "Radial X" -command "radialcallback 1";
button -label "Radial Y" -command "radialcallback 2";
button -label "Radial Z" -command "radialcallback 3";

setParent ..;
columnLayout -cat "both" 0 -cal "center" -cw 300;
text -h 50 -align "center" -label "Number of Pieces";

setParent ..;
columnLayout -co "both" 125 -cw 300;
intField -w 50 -minValue 3 -value 3 NumSides;


window -edit -wh 310 280 QuickSymm;
showWindow QuickSymm;

global proc instancecallback()
{
duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1) ;
}

global proc mirrorcallback(int $Linear)
{
switch($Linear)
{
case 1:
duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,-1,1,1);

break;
case 2:
duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,-1,1);
break;
case 3:
duplicatePreset(1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,-1);
break;

default:
break;
}
}

global proc radialcallback(int $MirrorAxis)
{
int $numInstances = `intField -q -value NumSides`;
float $Division = 360 / float ($numInstances);

switch($MirrorAxis)
{
case 1:
duplicatePreset(--$numInstances,0,1,0,0,0,0,0,0,0,0,$Division,0,0,1, 1,1);
break;

case 2:
duplicatePreset(--$numInstances,0,1,0,0,0,0,0,0,0,0,0,$Division,0,1, 1,1);
break;

case 3:
duplicatePreset(--$numInstances,0,1,0,0,0,0,0,0,0,0,0,0,$Division,1, 1,1);
break;

default:
break;
}
};

Shon Mitchell
11-05-2010, 04:30 PM
Another Update:

Packaged script better, now easier for implementing

Simply unzip, place QuickSymm.mel file into My Documents - Maya - 2011 (or whatever your verion is) - Scripts. Upon opening maya you can now just type QuickSymm; into your script line to load up, place QuickSymm; into your shelf, or set it to a hotkey. No more need to copy entire script into script editor

Shon Mitchell
01-26-2011, 09:03 AM
Added a Break Instance Button

Westsai
02-08-2011, 09:28 PM
Awesome! added to shelf... i'll be using this a lot! thanks!