Heres the GUI;
And the code (most of this is GUI orientated);
sc_gui();
proc sc_gui()
{
if (`window -exists "sc_gui"`) deleteUI "sc_gui";
window -w 150 -h 300 -t "Locator Randomiser" -
maximizeButton false -minimizeButton false sc_gui;
columnLayout;
string $sel[] = (`ls -sl`);
separator;
separator;
textFieldButtonGrp -label "Object:"
-text $sel
-buttonLabel "<<<"
-cw3 50 165 10
-ct3 "left" "both" "left"
-buttonCommand "sc_getObj()" selObj;
separator;
separator;
separator -style "double" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 1
-columnWidth 1 260;
text -al "left" " Frame Settings:";
setParent ..;
separator;
separator;
textFieldGrp -l "Start:"
-cw2 50 165 -text 1 start;
textFieldGrp -l "Finish:"
-cw2 50 165 -text 100 finish;
separator;
separator;
textFieldGrp -l "Min:"
-cw2 50 165 -text 1 minFrame;
textFieldGrp -l "Max:"
-cw2 50 165 -text 10 maxFrame;
separator;
separator;separator;
separator;
separator -style "double" -w 260;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0;
button -vis 0;
button -vis 0;
text "Min";
button -vis 0;
text "Movement Parameters";
button -vis 0;
text "Max";
button -vis 0;
button -vis 0;
setParent ..;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "X:"; //2
button -vis 0; //3
textField;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranX;//6
button -vis 0;//7
textField;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " x" randChkX;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "Y:"; //2
button -vis 0; //3
textField;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranY;//6
button -vis 0;//7
textField;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " Y" randChkY;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "Z:"; //2
button -vis 0; //3
textField;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranZ;//6
button -vis 0;//7
textField;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " Z" randChkZ;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 3;
button -vis 0 -w 160;
button -l "Key" -c sc_frameCount;
button -vis 0;
setParent ..;
separator;
separator;
showWindow "sc_gui";
}
proc sc_getObj()
{
string $sel[] = (`ls -sl`);
string $firstObj = $sel[0];
textFieldButtonGrp -edit -text $firstObj selObj;
print $firstObj;
}
proc sc_frameCount()
{
int $start = (`textFieldGrp -query -text start`);
int $end = (`textFieldGrp -query -text finish`);
int $min = (`textFieldGrp -query -text minFrame`);
int $max = (`textFieldGrp -query -text maxFrame`);
string $sel[] = (`select`);
string $Ty = "ty";
int $randX = (`checkBox -query -v randChkX`);
int $randY = (`checkBox -query -v randChkY`);
int $randZ = (`checkBox -query -v randChkZ`);
$currentFrame = $start;
if($randX == 1 || $randY == 1 || $randZ == 1)
{
print "test";
}
else{
for ($currentFrame > $start; $currentFrame <
$end;)
{
int $randGen = rand($min,$max);
string $selObj = (`textFieldButtonGrp -query -text
selObj`);
float $randMoveX = (`floatSlider -query -value
tranX`);
float $randMoveY = (`floatSlider -query -value
tranY`);
float $randMoveZ = (`floatSlider -query -value
tranZ`);
string $objAttrX = $selObj + ".translateX";
string $objAttrY = $selObj + ".translateY";
string $objAttrZ = $selObj + ".translateZ";
int $objAttrGetX = `getAttr $objAttrX`;
int $objAttrGetY = `getAttr $objAttrY`;
int $objAttrGetZ = `getAttr $objAttrZ`;
int $finalMoveX = ($objAttrGetX + $randMoveX);
int $finalMoveY = ($objAttrGetY + $randMoveY);
int $finalMoveZ = ($objAttrGetZ + $randMoveZ);
$currentFrame = ($currentFrame + $randGen);
currentTime -edit $currentFrame;
setAttr $objAttrX $finalMoveX;
setAttr $objAttrY $finalMoveY;
setAttr $objAttrZ $finalMoveZ;
print ($currentFrame + "\n");
print ($randMoveX + "\n");
print ($randMoveY + "\n");
print ($randMoveZ + "\n");
setKeyframe `textFieldButtonGrp -query
-text selObj`;
}
}
}
sc_gui();
proc sc_gui()
{
if (`window -exists "sc_gui"`) deleteUI "sc_gui";
window -w 150 -h 300 -t "Locator Randomiser" -
maximizeButton false -minimizeButton false sc_gui;
columnLayout;
string $sel[] = (`ls -sl`);
separator;
separator;
textFieldButtonGrp -label "Object:"
-text $sel
-buttonLabel "<<<"
-cw3 50 165 10
-ct3 "left" "both" "left"
-buttonCommand "sc_getObj()" selObj;
separator;
separator;
separator -style "double" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 1
-columnWidth 1 260;
text -al "left" " Frame Settings:";
setParent ..;
separator;
separator;
textFieldGrp -l "Start:"
-cw2 50 165 -text 1 start;
textFieldGrp -l "Finish:"
-cw2 50 165 -text 100 finish;
separator;
separator;
textFieldGrp -l "Min:"
-cw2 50 165 -text 1 minFrame;
textFieldGrp -l "Max:"
-cw2 50 165 -text 10 maxFrame;
separator;
separator;separator;
separator;
separator -style "double" -w 260;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0;
button -vis 0;
button -vis 0;
text "Min";
button -vis 0;
text "Movement Parameters";
button -vis 0;
text "Max";
button -vis 0;
button -vis 0;
setParent ..;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "X:"; //2
button -vis 0; //3
textField;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranX;//6
button -vis 0;//7
textField;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " x" randChkX;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "Y:"; //2
button -vis 0; //3
textField;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranY;//6
button -vis 0;//7
textField;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " Y" randChkY;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 11
-columnWidth 1 5
-columnWidth 2 10
-columnWidth 3 5
-columnWidth 4 45
-columnWidth 5 5
-columnWidth 6 130
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
-columnWidth 10 5
-columnWidth 11 5
;
button -vis 0; //1
text "Z:"; //2
button -vis 0; //3
textField;//4
button -vis 0;//5
floatSlider -min -10 -max 10 tranZ;//6
button -vis 0;//7
textField;//8
button -vis 0 ;//9
button -vis 0;//10
button -vis 0;//11
setParent..;
rowColumnLayout -numberOfColumns 9
-columnWidth 1 5
-columnWidth 2 50
-columnWidth 3 5
-columnWidth 4 20
-columnWidth 5 45
-columnWidth 6 75
-columnWidth 7 5
-columnWidth 8 45
-columnWidth 9 5
;
button -vis 0;//1
text "Random:";//2
button -vis 0;//3
checkBox -l " Z" randChkZ;//4
button -vis 0;//5
button -vis 0;//6
button -vis 0;//7
button -l "Apply";//8
button -vis 0;//9
setParent..;
separator;
separator;
separator -style "single" -w 260;
separator;
separator;
rowColumnLayout -numberOfColumns 3;
button -vis 0 -w 160;
button -l "Key" -c sc_frameCount;
button -vis 0;
setParent ..;
separator;
separator;
showWindow "sc_gui";
}
proc sc_getObj()
{
string $sel[] = (`ls -sl`);
string $firstObj = $sel[0];
textFieldButtonGrp -edit -text $firstObj selObj;
print $firstObj;
}
proc sc_frameCount()
{
int $start = (`textFieldGrp -query -text start`);
int $end = (`textFieldGrp -query -text finish`);
int $min = (`textFieldGrp -query -text minFrame`);
int $max = (`textFieldGrp -query -text maxFrame`);
string $sel[] = (`select`);
string $Ty = "ty";
int $randX = (`checkBox -query -v randChkX`);
int $randY = (`checkBox -query -v randChkY`);
int $randZ = (`checkBox -query -v randChkZ`);
$currentFrame = $start;
if($randX == 1 || $randY == 1 || $randZ == 1)
{
print "test";
}
else{
for ($currentFrame > $start; $currentFrame <
$end;)
{
int $randGen = rand($min,$max);
string $selObj = (`textFieldButtonGrp -query -text
selObj`);
float $randMoveX = (`floatSlider -query -value
tranX`);
float $randMoveY = (`floatSlider -query -value
tranY`);
float $randMoveZ = (`floatSlider -query -value
tranZ`);
string $objAttrX = $selObj + ".translateX";
string $objAttrY = $selObj + ".translateY";
string $objAttrZ = $selObj + ".translateZ";
int $objAttrGetX = `getAttr $objAttrX`;
int $objAttrGetY = `getAttr $objAttrY`;
int $objAttrGetZ = `getAttr $objAttrZ`;
int $finalMoveX = ($objAttrGetX + $randMoveX);
int $finalMoveY = ($objAttrGetY + $randMoveY);
int $finalMoveZ = ($objAttrGetZ + $randMoveZ);
$currentFrame = ($currentFrame + $randGen);
currentTime -edit $currentFrame;
setAttr $objAttrX $finalMoveX;
setAttr $objAttrY $finalMoveY;
setAttr $objAttrZ $finalMoveZ;
print ($currentFrame + "\n");
print ($randMoveX + "\n");
print ($randMoveY + "\n");
print ($randMoveZ + "\n");
setKeyframe `textFieldButtonGrp -query
-text selObj`;
}
}
}
sc_gui();
No comments:
Post a Comment