forked from pomettini/maya-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
randomizer.mel
149 lines (130 loc) · 5.27 KB
/
randomizer.mel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
string $window = "Window";
// If window already exists, it deletes it
if (`window -q -ex $window`)
{
deleteUI $window;
}
// I make a new window
window -t "Randomizer" $window;
window -e -h 100 -w 200 $window;
// Start of the Translation panel
frameLayout -label "Randomize Translation" -collapsable 1;
columnLayout -adj true;
columnLayout;
floatSliderGrp -label "X Min: " -field true -min -10 -max 10 -value -5 minPosX;
floatSliderGrp -label "X Max: " -field true -min -10 -max 10 -value 5 maxPosX;
setParent..;
columnLayout;
floatSliderGrp -label "Y Min: " -field true -min -10 -max 10 -value -5 minPosY;
floatSliderGrp -label "Y Max: " -field true -min -10 -max 10 -value 5 maxPosY;
setParent..;
columnLayout;
floatSliderGrp -label "Z Min: " -field true -min -10 -max 10 -value -5 minPosZ;
floatSliderGrp -label "Z Max: " -field true -min -10 -max 10 -value 5 maxPosZ;
setParent..;
button -label "Randomize Translation" -command "RandomizeTranslation()";
setParent..;
setParent..;
// End of the Translation panel
// Start of the Rotation panel
frameLayout -label "Randomize Rotation" -collapsable 1;
columnLayout -adj true;
columnLayout;
floatSliderGrp -label "X Min: " -field true -min 0 -max 360 -value 0 minRotX;
floatSliderGrp -label "X Max: " -field true -min 0 -max 360 -value 360 maxRotX;
setParent..;
columnLayout;
floatSliderGrp -label "Y Min: " -field true -min 0 -max 360 -value 0 minRotY;
floatSliderGrp -label "Y Max: " -field true -min 0 -max 360 -value 360 maxRotY;
setParent..;
columnLayout;
floatSliderGrp -label "Z Min: " -field true -min 0 -max 360 -value 0 minRotZ;
floatSliderGrp -label "Z Max: " -field true -min 0 -max 360 -value 360 maxRotZ;
setParent..;
button -label "Randomize Rotation" -command "RandomizeRotation()";
setParent..;
setParent..;
// Start of the Rotation panel
// Start of the Scale panel
frameLayout -label "Randomize Scale" -collapsable 1;
columnLayout -adj true;
columnLayout;
floatSliderGrp -label "X Min: " -field true -min 0 -max 10 -value 1 minScaleX;
floatSliderGrp -label "X Max: " -field true -min 0 -max 10 -value 2 maxScaleX;
setParent..;
columnLayout;
floatSliderGrp -label "Y Min: " -field true -min 0 -max 10 -value 1 minScaleY;
floatSliderGrp -label "Y Max: " -field true -min 0 -max 10 -value 2 maxScaleY;
setParent..;
columnLayout;
floatSliderGrp -label "Z Min: " -field true -min 0 -max 10 -value 1 minScaleZ;
floatSliderGrp -label "Z Max: " -field true -min 0 -max 10 -value 2 maxScaleZ;
setParent..;
button -label "Randomize Scale" -command "RandomizeScale()";
setParent..;
setParent..;
// End of the Scale panel
showWindow;
global proc RandomizeTranslation()
{
// I put the selection into an array
string $selection[] = `ls -sl`;
for ($element in $selection)
{
// I get the value of the sliders
float $minX = `floatSliderGrp -q -value minPosX`;
float $minY = `floatSliderGrp -q -value minPosY`;
float $minZ = `floatSliderGrp -q -value minPosZ`;
float $maxX = `floatSliderGrp -q -value maxPosX`;
float $maxY = `floatSliderGrp -q -value maxPosY`;
float $maxZ = `floatSliderGrp -q -value maxPosZ`;
// I get a random value between the minimum and maximum value
float $randX = rand($minX, $maxX);
float $randY = rand($minY, $maxY);
float $randZ = rand($minZ, $maxZ);
// I set the translate of the objects based on the random number
setAttr ($element + ".translate") $randX $randY $randZ;
}
}
global proc RandomizeRotation()
{
// I put the selection into an array
string $selection[] = `ls -sl`;
for ($element in $selection)
{
// I get the value of the sliders
float $minX = `floatSliderGrp -q -value minRotX`;
float $minY = `floatSliderGrp -q -value minRotY`;
float $minZ = `floatSliderGrp -q -value minRotZ`;
float $maxX = `floatSliderGrp -q -value maxRotX`;
float $maxY = `floatSliderGrp -q -value maxRotY`;
float $maxZ = `floatSliderGrp -q -value maxRotZ`;
// I get a random value between the minimum and maximum value
float $randX = rand($minX, $maxX);
float $randY = rand($minY, $maxY);
float $randZ = rand($minZ, $maxZ);
// I set the rotation of the objects based on the random number
setAttr ($element + ".rotate") $randX $randY $randZ;
}
}
global proc RandomizeScale()
{
// I put the selection into an array
string $selection[] = `ls -sl`;
for ($element in $selection)
{
// I get the value of the sliders
float $minX = `floatSliderGrp -q -value minScaleX`;
float $minY = `floatSliderGrp -q -value minScaleY`;
float $minZ = `floatSliderGrp -q -value minScaleZ`;
float $maxX = `floatSliderGrp -q -value maxScaleX`;
float $maxY = `floatSliderGrp -q -value maxScaleY`;
float $maxZ = `floatSliderGrp -q -value maxScaleZ`;
// I get a random value between the minimum and maximum value
float $randX = rand($minX, $maxX);
float $randY = rand($minY, $maxY);
float $randZ = rand($minZ, $maxZ);
// I set the scale of the objects based on the random number
setAttr ($element + ".scale") $randX $randY $randZ;
}
}