This repository has been archived by the owner on Dec 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QuickPose.py
303 lines (237 loc) · 10.8 KB
/
QuickPose.py
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import maya.cmds as cmds
def showAbout():
cmds.confirmDialog( title='About', message='Values Default to 0,0,0. Save a collection of objects using sets, find them in the outliner. Select the items in order and then set then use the revert functions. \nQuick Poser, Tim Kelly 2017')
def updateSlot(currentValue):
currentValue = cmds.optionMenu(save_Slot, query=True, value=True)
print 'Slot',currentValue
return currentValue
def setRotate(*args):
objects = cmds.ls(sl=True)
#increment for each item in the array
currentValue = cmds.optionMenu(save_Slot, query=True, value=True)
if int (currentValue) ==1:
i=0
for o in objects:
cmds.setAttr(o + '.rotateX', x_rotate_1[i])
cmds.setAttr(o + '.rotateY', y_rotate_1[i])
cmds.setAttr(o + '.rotateZ', z_rotate_1[i])
print o, x_rotate_1[i], y_rotate_1[i], z_rotate_1[i], "| Object rotations loaded from Slot 1"
i+=1
if int (currentValue) == 2:
i=0
for o in objects:
cmds.setAttr(o + '.rotateX', x_rotate_2[i])
cmds.setAttr(o + '.rotateY', y_rotate_2[i])
cmds.setAttr(o + '.rotateZ', z_rotate_2[i])
print o, x_rotate_2[i], y_rotate_2[i], z_rotate_2[i], "| Object rotations loaded from Slot 2"
i+=1
if int (currentValue) == 3:
i=0
for o in objects:
cmds.setAttr(o + '.rotateX', x_rotate_3[i])
cmds.setAttr(o + '.rotateY', y_rotate_3[i])
cmds.setAttr(o + '.rotateZ', z_rotate_3[i])
print o, x_rotate_3[i], y_rotate_3[i], z_rotate_3[i], "| Object rotations loaded from Slot 3"
i+=1
def getRotate(*args):
#clear the list of data and start again
objects = cmds.ls(sl=True)
numberObjectsSel = len(objects)
currentValue = cmds.optionMenu(save_Slot, query=True, value=True)
if '1' in currentValue:
del x_rotate_1[:]
del y_rotate_1[:]
del z_rotate_1[:]
if '2' in currentValue:
del x_rotate_2[:]
del y_rotate_2[:]
del z_rotate_2[:]
if '3' in currentValue:
del x_rotate_3[:]
del y_rotate_3[:]
del z_rotate_3[:]
#object selected?
if numberObjectsSel==0 :
print 'No objects selected'
else:
for o in objects:
readRotateX=cmds.getAttr(o + '.rotateX')
readRotateY=cmds.getAttr(o + '.rotateY')
readRotateZ=cmds.getAttr(o + '.rotateZ')
if '1' in currentValue:
x_rotate_1.insert(0,readRotateX)
y_rotate_1.insert(0,readRotateY)
z_rotate_1.insert(0,readRotateZ)
if '2' in currentValue:
x_rotate_2.insert(0,readRotateX)
y_rotate_2.insert(0,readRotateY)
z_rotate_2.insert(0,readRotateZ)
if '3' in currentValue:
x_rotate_3.insert(0,readRotateX)
y_rotate_3.insert(0,readRotateY)
z_rotate_3.insert(0,readRotateZ)
if '1' in currentValue:
x_rotate_1.reverse()
y_rotate_1.reverse()
z_rotate_1.reverse()
if numberObjectsSel != 0:
print objects,"X",x_rotate_1,"Y",y_rotate_1, "Z",z_rotate_1, " | Object translations saved to Slot 1"
return objects,x_rotate_1, y_rotate_1, z_rotate_1
if '2' in currentValue:
x_rotate_2.reverse()
y_rotate_2.reverse()
z_rotate_2.reverse()
if numberObjectsSel != 0:
print objects,"X",x_rotate_2,"Y",y_rotate_2, "Z",z_rotate_2, " | Object translations saved to Slot 2"
return objects,x_rotate_2, y_rotate_2, z_rotate_2
if '3' in currentValue:
x_rotate_3.reverse()
y_rotate_3.reverse()
z_rotate_3.reverse()
if numberObjectsSel != 0:
print objects,"X",x_rotate_3,"Y",y_rotate_3, "Z",z_rotate_3, " | Object translations saved to Slot 3"
return objects,x_rotate_3, y_rotate_3, z_rotate_3
def setTrans(*args):
objects = cmds.ls(sl=True)
numberObjectsSel = len(objects)
currentValue = cmds.optionMenu(save_Slot, query=True, value=True)
if int (currentValue) ==1:
i=0
for o in objects:
cmds.setAttr(o + '.translateX', x_trans_1[i])
cmds.setAttr(o + '.translateY', y_trans_1[i])
cmds.setAttr(o + '.translateZ', z_trans_1[i])
print o, x_trans_1[i], y_trans_1[i], z_trans_1[i], "|Object translations loaded from Slot 1"
i+=1
if int (currentValue) ==2:
i=0
for o in objects:
cmds.setAttr(o + '.translateX', x_trans_2[i])
cmds.setAttr(o + '.translateY', y_trans_2[i])
cmds.setAttr(o + '.translateZ', z_trans_2[i])
print o, x_trans_2[i], y_trans_2[i], z_trans_2[i], "|Object translations loaded from Slot 2"
i+=1
if int (currentValue) ==3:
i=0
for o in objects:
cmds.setAttr(o + '.translateX', x_trans_3[i])
cmds.setAttr(o + '.translateY', y_trans_3[i])
cmds.setAttr(o + '.translateZ', z_trans_3[i])
print o, x_trans_3[i], y_trans_3[i], z_trans_3[i], "|Object translations loaded from Slot 3"
i+=1
def getTrans(*args):
#clear the list of data and start again
objects = cmds.ls(sl=True)
numberObjectsSel = len(objects)
currentValue = cmds.optionMenu(save_Slot, query=True, value=True)
if '1' in currentValue:
del x_trans_1[:]
del y_trans_1[:]
del z_trans_1[:]
if '2' in currentValue:
del x_trans_2[:]
del y_trans_2[:]
del z_trans_2[:]
if '3' in currentValue:
del x_trans_3[:]
del y_trans_3[:]
del z_trans_3[:]
#object selected?
if numberObjectsSel==0 :
print 'No objects selected'
else:
for o in objects:
readTransX=cmds.getAttr(o + '.translateX')
readTransY=cmds.getAttr(o + '.translateY')
readTransZ=cmds.getAttr(o + '.translateZ')
if '1' in currentValue:
x_trans_1.insert(0,readTransX)
y_trans_1.insert(0,readTransY)
z_trans_1.insert(0,readTransZ)
if '2' in currentValue:
x_trans_2.insert(0,readTransX)
y_trans_2.insert(0,readTransY)
z_trans_2.insert(0,readTransZ)
if '3' in currentValue:
x_trans_3.insert(0,readTransX)
y_trans_3.insert(0,readTransY)
z_trans_3.insert(0,readTransZ)
if '1' in currentValue:
x_trans_1.reverse()
y_trans_1.reverse()
z_trans_1.reverse()
if numberObjectsSel != 0:
print objects,"X",x_trans_1,"Y",y_trans_1, "Z",z_trans_1, " | Object translations saved to Slot 1"
return objects,x_trans_1, y_trans_1, z_trans_1
if '2' in currentValue:
x_trans_2.reverse()
y_trans_2.reverse()
z_trans_2.reverse()
if numberObjectsSel != 0:
print objects,"X",x_trans_2,"Y",y_trans_2, "Z",z_trans_2, " | Object translations saved to Slot 2"
return objects,x_trans_1, y_trans_1, z_trans_1
if '1' in currentValue:
x_trans_3.reverse()
y_trans_3.reverse()
z_trans_3.reverse()
if numberObjectsSel != 0:
print objects,"X",x_trans_3,"Y",y_trans_3, "Z",z_trans_3, " | Object translations saved to Slot 3"
return objects,x_trans_3, y_trans_3, z_trans_3
def zero(*args):
objects = cmds.ls(sl=True)
numberObjectsSel = len(objects)
#object selected?
if numberObjectsSel==0 :
print 'No objects selected'
else:
for o in objects:
cmds.setAttr(o + '.rotateX', 0)
cmds.setAttr(o + '.rotateY', 0)
cmds.setAttr(o + '.rotateZ', 0)
cmds.setAttr(o + '.translateX', 0)
cmds.setAttr(o + '.translateY', 0)
cmds.setAttr(o + '.translateZ', 0)
print o,"| Object properties set to 0"
def quickSelect(*args):
currentValue = cmds.optionMenu(save_Slot, query=True, value=True)
if '1' in currentValue:
set1 =cmds.sets(name='SET1')
if '2' in currentValue:
set2 =cmds.sets(name='SET2')
if '3' in currentValue:
set3 =cmds.sets(name='SET3')
cmds.window( width=325, height=100, title ="Quick Poser Tim Kelly 13th Dec" )
cmds.columnLayout( adjustableColumn=True )
cmds.nodeIconButton( style='iconAndTextHorizontal', label='Revert Rotate', align='left', command=setRotate, image1='sphere.xpm')
cmds.nodeIconButton( style='iconAndTextHorizontal', label='Save Rotate', align='center', command=getRotate, image1='sphere.xpm')
cmds.nodeIconButton( style='iconAndTextHorizontal', label='Revert Translate', align='left', command=setTrans, image1='cube.xpm')
cmds.nodeIconButton( style='iconAndTextHorizontal', label='Save Translate', align='center', command=getTrans, image1='cube.xpm')
cmds.nodeIconButton( style='iconAndTextHorizontal', label='Make Quick Select', align='center', command=quickSelect, image1='cylinder.xpm')
cmds.nodeIconButton( style='iconAndTextHorizontal', label='Zero Out', align='center', command=zero, image1='torus.xpm')
cmds.nodeIconButton( style='iconAndTextHorizontal', label='About', align='center', command=showAbout, image1='cone.xpm')
save_Slot = cmds.optionMenu( label='Slot Number: ', changeCommand=updateSlot )
cmds.menuItem(label='1')
cmds.menuItem(label='2')
cmds.menuItem(label='3')
x_rotate_1 = [0,0,0]
y_rotate_1 = [0,0,0]
z_rotate_1 = [0,0,0]
x_trans_1 = [0,0,0]
y_trans_1 = [0,0,0]
z_trans_1 = [0,0,0]
x_rotate_2 = [0,0,0]
y_rotate_2 = [0,0,0]
z_rotate_2 = [0,0,0]
x_trans_2 = [0,0,0]
y_trans_2 = [0,0,0]
z_trans_2 = [0,0,0]
x_rotate_3 = [0,0,0]
y_rotate_3 = [0,0,0]
z_rotate_3 = [0,0,0]
x_trans_3 = [0,0,0]
y_trans_3 = [0,0,0]
z_trans_3 = [0,0,0]
currentValue = 0
objects = []
set1 = []
cmds.showWindow()