/
tkVirtualProductionHelperUI.py
505 lines (356 loc) · 16.5 KB
/
tkVirtualProductionHelperUI.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# tkVirtualProductionHelper.py
import maya.cmds as cmds
import maya.mel as mel
from functools import partial
# import thomas as tk
'''
Tools for zorro sim
---------------------------------------------------
'''
ver = '1.0'
colDarkGreen = [0.1, 0.16, 0.08]
colFrame = [0.3, 0.3, 0.3]
colFrameRed = [0.4, 0.3, 0.3]
colDarkRed = [0.32, 0.2, 0.14]
colFrameGreen = [0.3, 0.4, 0.28]
colLightGreen = [0.4, 0.5, 0.36]
colDark = [0.1, 0.1, 0.1]
colBlue = [0.32, 0.2, 0.14]
colBrown = [0.1, 0.16, 0.08]
defaultPath = 'X:/zorro_zor-5069/_library/assets/characters/chr_zorroFox/cfx_groom/'
approvedxGen = 'zor_chr_zorroFox_cfx_groom_v080_thk__body_collection'
xGenBaseGeo = 'body_cn_hi_cfx'
dynControl = 'dyn_GRP'
windowStartHeight = 50
windowStartWidth = 200
bh1 = 24
def tkHelpSwitchInstancerInputs(*args):
if cmds.window('win_tkSwitchInstancerINPUtsHELP', exists=1):
cmds.deleteUI('win_tkSwitchInstancerINPUtsHELP')
myWindow = cmds.window('win_tkSwitchInstancerINPUtsHELP', s=1, t='help', wh=[200, 200])
helpText = 'Replace instanced references without changing order\n---------------------------------------------------\nInstancer: Choose Instancer \nUses The namespace of the first connected obj\nReplace With: Select file you want to replace from\n Gets the namespace automatically'
cmds.columnLayout(adj=1)
cmds.text(helpText, al='left')
cmds.showWindow(myWindow )
def cShrinkWin(windowToClose, *args):
cmds.window(windowToClose, e=1, h=20)
cmds.window(windowToClose, e=1, w=420)
def tk_linkAnimToCloth(action, *args):
CLT = ['cape_cn_cfx_mid_geo_oneSided', 'shirt_cn_cfx_mid_geo_oneSided',
'cape_cn_cfx_hi_geo_oneSided', 'shirt_cn_cfx_hi_geo_oneSided',
'leatherSheath_cn_lo_geo', 'metalSheath_cn_lo_geo', 'beltBuckle_cn_lo_geo',
'belt_cn_lo_geo', 'beltSheathLong_cn_lo_geo', 'beltSheathWide_cn_lo_geo', 'furVolume_cn_mid_anim_geo',
'body_cn_hi_cfx']
failList = []
fails = ''
nmSpcAnim = cmds.textField('tfNmSpcAnim', tx=1, q=1)
nmSpcFX = cmds.textField('tfNmSpcFX', tx=1, q=1)
if nmSpcAnim:
nmSpcAnim = nmSpcAnim + ':'
nmSpcFX = nmSpcFX + ':'
for i in CLT:
if cmds.objExists(nmSpcFX + i) is False:
failList.append(i)
if cmds.objExists(nmSpcAnim + i) is False:
failList.append(i)
if len(failList) > 0:
print '-------------------------'
print 'Missing objects:'
for fail in failList:
fails += fail + ' '
print fail
cClear('tfFeedback', ('Missing objects! Check the Script Editor for details!'), [.3, 0, 0])
print '-------------------------'
else:
print '-------------------------'
for clt in CLT:
# print clt
shapes = cmds.listRelatives(nmSpcFX + clt, s=1)
# disconnect
if action == 0:
if cmds.objExists('BS_' + clt):
print 'disconnecting ' + clt
bs = cmds.listConnections(shapes[0], s=1, d=0, type='blendShape')
cmds.setAttr(bs[0] + '.' + clt, 0)
cmds.delete(bs)
# connect
if action == 1:
if not cmds.objExists('BS_' + clt):
print 'connecting ' + clt
cmds.select(nmSpcAnim + clt, nmSpcFX + clt)
mel.eval('performBlendShape 0 1')
bs = cmds.listConnections(shapes[0], s=1, d=0, type='blendShape')
bs = cmds.rename(bs[0], 'BS_' + clt)
# print 'bs:'
# print bs
cmds.setAttr(bs + '.' + clt, 1)
else:
print (clt + ' is already connected - disconnect first!')
print '-------------------------'
if action == 1:
cClear('tfFeedback', 'Successfully linked anim to FX!', [0, 0.3, 0])
if action == 0:
cClear('tfFeedback', 'Successfully disconnected anim from FX!', [0, 0.3, 0])
def cGetNmSpc(field, *args):
curSel = cmds.ls(sl=1)
if curSel:
if ':' in curSel[0]:
cmds.textField(field, tx=curSel[0].split(':')[0], e=1)
else:
cmds.textField(field, tx='', e=1)
else:
cmds.textField(field, tx='', e=1)
def tkSetVisibility(object, *args):
animGrp = 'ANIM_GRP'
animGrpHi = 'ANIM_hi_GRP'
wrapGrp = 'wrap_GRP'
collGrp = 'passive_GRP'
exClothGrp = 'export_cloth_GRP'
xGenBaseGrp = 'xGenBase_GRP'
nmSpc = cmds.textField('tfNmSpcAnim', tx=1, q=1)
nmSpcFX = cmds.textField('tfNmSpcFX', tx=1, q=1)
if nmSpc:
nmSpc = nmSpc + ':'
if nmSpcFX:
nmSpcFX = nmSpcFX + ':'
if object is 'Anim':
low = cmds.checkBox('cbLow', v=1, q=1)
mid = cmds.checkBox('cbMid', v=1, q=1)
hgh = cmds.checkBox('cbHgh', v=1, q=1)
but = cmds.checkBox('cbButtons', v=1, q=1)
if cmds.objExists(nmSpc + 'furVolume_cn_mid_anim_geo') is False:
cClear('tfFeedback', 'Objects not found! Check the namespace!', [.3, 0, 0])
else:
dagList = cmds.ls(nmSpc + '*_lo_*', type='transform')
for i in dagList:
print i
cmds.setAttr(i + '.v', low)
dagList = cmds.ls(nmSpc + '*_mid_*', type='transform')
for i in dagList:
print i
cmds.setAttr(i + '.v', mid)
dagList = cmds.ls(nmSpc + '*_hi_*', type='transform')
for i in dagList:
print i
cmds.setAttr(i + '.v', hgh)
dagList = cmds.ls(nmSpc + '*button_*', type='transform')
for i in dagList:
print i
cmds.setAttr(i + '.v', but)
if object is 'FX':
anim = cmds.checkBox('cbAnimGRP', v=1, q=1)
animHi = cmds.checkBox('cbAnimHiGRP', v=1, q=1)
coll = cmds.checkBox('cbColliderGRP', v=1, q=1)
wrap = cmds.checkBox('cbWrapGRP', v=1, q=1)
cape = cmds.checkBox('cbCape', v=1, q=1)
shirt = cmds.checkBox('cbShirt', v=1, q=1)
exCloth = cmds.checkBox('cbExportClothGRP', v=1, q=1)
xGenBase = cmds.checkBox('cbxGenBase', v=1, q=1)
if cmds.objExists(nmSpcFX + collGrp) is False:
cClear('tfFeedback', 'Objects not found! Check the namespace!', [.3, 0, 0])
else:
cmds.setAttr(nmSpcFX + collGrp + '.v', coll)
children = cmds.listRelatives(nmSpcFX + collGrp, c=1, type = 'transform')
for child in children:
cmds.setAttr(child + '.v', coll)
cmds.setAttr(nmSpcFX + animGrp + '.v', anim)
children = cmds.listRelatives(nmSpcFX + animGrp, c=1, type = 'transform')
for child in children:
cmds.setAttr(child + '.v', anim)
cmds.setAttr(nmSpcFX + animGrpHi + '.v', animHi)
children = cmds.listRelatives(nmSpcFX + animGrpHi, c=1, type = 'transform')
for child in children:
cmds.setAttr(child + '.v', animHi)
cmds.setAttr(nmSpcFX + wrapGrp + '.v', wrap)
children = cmds.listRelatives(nmSpcFX + wrapGrp, c=1, type = 'transform')
for child in children:
cmds.setAttr(child + '.v', wrap)
cmds.setAttr(nmSpcFX + exClothGrp + '.v', exCloth)
children = cmds.listRelatives(nmSpcFX + exClothGrp, c=1, type = 'transform')
for child in children:
cmds.setAttr(child + '.v', exCloth)
cmds.setAttr(nmSpcFX + xGenBaseGrp + '.v', xGenBase)
children = cmds.listRelatives(nmSpcFX + xGenBaseGrp, c=1, type = 'transform')
for child in children:
cmds.setAttr(child + '.v', xGenBase)
cmds.setAttr(nmSpcFX + dynControl + '.cape', cape)
cmds.setAttr(nmSpcFX + dynControl + '.shirt', shirt)
def tkTglAll(object, *args):
listFX = ['cbAnimGRP', 'cbAnimHiGRP', 'cbColliderGRP', 'cbShirt', 'cbCape', 'cbWrapGRP', 'cbExportClothGRP', 'cbxGenBase']
listAnim = ['cbLow', 'cbMid', 'cbHgh', 'cbButtons']
if object is 'FX':
state = cmds.checkBox(listFX[0], v=1, q=1) -1
for i in listFX:
cmds.checkBox(i, v=state, e=1)
if object is 'Anim':
state = cmds.checkBox(listAnim[0], v=1, q=1) -1
for i in listAnim:
cmds.checkBox(i, v=state, e=1)
def cSelect(object, *args):
nmSpcFX = cmds.textField('tfNmSpcFX', tx=1, q=1)
if nmSpcFX:
nmSpcFX = nmSpcFX + ':'
if cmds.objExists(nmSpcFX + object) is False:
cClear('tfFeedback', 'Objects not found! Check the namespace!', [.3, 0, 0])
else:
cmds.select(nmSpcFX + object, r=1)
def cSelectSimELements(object, *args):
CLT = []
nmSpcFX = cmds.textField('tfNmSpcFX', tx=1, q=1)
if nmSpcFX:
nmSpcFX = nmSpcFX + ':'
if cmds.objExists(nmSpcFX + 'shirt_cn_cfx_mid_geo_SIM') is False:
cClear('tfFeedback', 'Objects not found! Check the namespace!', [.3, 0, 0])
else:
if (object == 'shirtMid'):
CLT = ['shirt_cn_cfx_mid_geo_SIM']
cmds.setAttr(nmSpcFX + dynControl + '.shirt', 1)
if (object == 'capeMid'):
CLT = ['cape_cn_cfx_mid_geo_SIM']
cmds.setAttr(nmSpcFX + dynControl + '.cape', 1)
cmds.checkBox('cbCape', v=1, e=1)
if (object == 'bothMid'):
CLT = ['cape_cn_cfx_mid_geo_SIM', 'shirt_cn_cfx_mid_geo_SIM']
cmds.setAttr(nmSpcFX + dynControl + '.shirt', 1)
cmds.setAttr(nmSpcFX + dynControl + '.cape', 1)
cmds.checkBox('cbCape', v=1, e=1)
cmds.checkBox('cbShirt', v=1, e=1)
if (object == 'shirtHi'):
CLT = ['shirt_cn_cfx_hi_geo_SIM']
cmds.setAttr(nmSpcFX + dynControl + '.shirt', 2)
cmds.checkBox('cbShirt', v=1, e=1)
if (object == 'capeHi'):
CLT = ['cape_cn_cfx_hi_geo_SIM']
cmds.setAttr(nmSpcFX + dynControl + '.cape', 2)
cmds.checkBox('cbCape', v=1, e=1)
if (object == 'bothHi'):
CLT = ['cape_cn_cfx_hi_geo_SIM', 'shirt_cn_cfx_hi_geo_SIM']
cmds.setAttr(nmSpcFX + dynControl + '.shirt', 2)
cmds.setAttr(nmSpcFX + dynControl + '.cape', 2)
cmds.checkBox('cbCape', v=1, e=1)
cmds.checkBox('cbShirt', v=1, e=1)
if (object == 'none'):
CLT = []
cmds.setAttr(nmSpcFX + dynControl + '.shirt', 0)
cmds.setAttr(nmSpcFX + dynControl + '.cape', 0)
cmds.checkBox('cbCape', v=0, e=1)
cmds.checkBox('cbShirt', v=0, e=1)
cmds.select(clear=1)
if nmSpcFX:
nmSpcFX = nmSpcFX + ':'
for clt in CLT:
cmds.select(nmSpcFX + clt, add=1)
else:
cmds.select(CLT, r=1)
def cSelectFXAnimELements(*args):
nmSpcFX = cmds.textField('tfNmSpcFX', tx=1, q=1)
grp = 'ANIM_GRP'
if nmSpcFX:
nmSpcFX = nmSpcFX + ':'
if cmds.objExists(nmSpcFX + grp) is False:
cClear('tfFeedback', 'Objects not found! Check the namespace!', [.3, 0, 0])
else:
cmds.select(nmSpcFX + grp, r=1)
cmds.select(nmSpcFX + 'xGenBase_GRP', add=1)
def cExportAsABC(*args):
mel.eval('AlembicExportSelectionOptions')
def cReferenceAnimABC(*args):
mel.eval(' projectViewer AlembicReference')
def cClothCache(*args):
mel.eval('doCreateNclothCache 5 { "2", "1", "10", "OneFile", "1", "","0","","0", "0", "0", "1", "1","0","1","mcx" }')
def cDeleteCache(*args):
mel.eval('fluidDeleteCache')
def cWrapStatus(action, field, attribute, *args):
nmSpcFX = cmds.textField('tfNmSpcFX', tx=1, q=1)
if nmSpcFX:
nmSpcFX = nmSpcFX + ':'
if action == 'read':
sl = cmds.getAttr(nmSpcFX + dynControl + '.' + attribute) +1
# print sl
cmds.radioButtonGrp(field, sl=sl, e=1)
if action is 'set':
sl = cmds.radioButtonGrp(field, sl=1, q=1) -1
# print sl
cmds.setAttr(nmSpcFX + dynControl + '.' + attribute, sl)
# print '--------------'
def cGetPath(action, *args):
defaultPath = "X:/zorro_zor-5069/_library/assets/characters/chr_zorroFox/cfx_groom/"
if action == 'default':
cmds.textField('tfPathxGen', tx=defaultPath, e=1)
cmds.textField('xGenVersion', tx=approvedxGen, e=1)
if action == 'choose':
xGenPath = cmds.fileDialog2(fm=2, ds=1, dir=defaultPath, cap='Select Directory')
cmds.textField('tfPathxGen', tx=xGenPath[0] + '/', e=1)
files = cmds.getFileList(filespec = '*.xgen', fld=xGenPath[0])
if files:
if approvedxGen not in files:
cmds.textField('xGenVersion', tx='Choose a xGen Collection!', e=1)
else:
cmds.textField('xGenVersion', tx='No xGen descriptions in that Folder!', e=1)
def cSelectxGenVersion(action, *args):
xGenPath = cmds.textField('tfPathxGen', tx=1, q=1)
cmdAppend = '['
if xGenPath:
files = cmds.getFileList(filespec = '*.xgen', fld=xGenPath)
files = sorted(files)
if (cmds.window('win_xGenList', exists=1)):
cmds.deleteUI('win_xGenList')
myVersionWindow = cmds.window('win_xGenList', t=('Fox xGen Versions'), s=1)
cmds.columnLayout(adj=1)
amount = len(files)
if amount > 0:
for i in range(0, amount-1, 1):
name = files[i].split('.')[0]
if i != amount-2:
cmdAppend += '"'
cmdAppend += name
cmdAppend += '",'
else:
cmdAppend += '"'
cmdAppend += name
cmdAppend += '"]'
cmd1 = 'cmds.textScrollList("txGenVersion", numberOfRows=8, append= '
cmd2 = ')'
cmd = cmd1 + cmdAppend + cmd2
cmds.paneLayout()
exec(cmd)
cmds.setParent('..')
cmds.button(l='Pick Version', bgc=(colDarkGreen[0], colDarkGreen[1], colDarkGreen[2]), c=partial(tfSelectxGenVersion))
cmds.showWindow(myVersionWindow)
cmds.window(myVersionWindow, e=1,h=120)
else:
cmds.textField('xGenVersion', tx='No xGen descriptions in that Folder!', e=1)
def tfSelectxGenVersion(*args):
chosenVersion = cmds.textScrollList('txGenVersion', si=1, q=1)
cmds.deleteUI('win_xGenList')
cmds.textField('xGenVersion', tx=chosenVersion[0], e=1)
def cImportxGen(action, *args):
path = cmds.textField('tfPathxGen', tx=1, q=1)
file = cmds.textField('xGenVersion', tx=1, q=1)
nmSpcFX = cmds.textField('tfNmSpcFX', tx=1, q=1)
if nmSpcFX:
nmSpcFX = nmSpcFX + ':'
if cmds.objExists(nmSpcFX + xGenBaseGeo):
pass
def cClear(field, text, color, *args):
cmds.textField(field, tx=text, bgc=color, e=1)
def tkVirtualProductionHelperUI(*args):
if (cmds.window('win_tkVirtualProductionHelper', exists=1)):
cmds.deleteUI('win_tkVirtualProductionHelper')
myWindow = cmds.window('win_tkVirtualProductionHelper', t=('Virtual Production Helper' + ver), s=1)
cmds.columnLayout(adj=1, bgc=(colDarkGreen[0], colDarkGreen[1], colDarkGreen[2]))
# name space
# cmds.rowColumnLayout(nc=4, cw = [(1, 120), (2, 90), (3, 120), (4, 90)])
# cmds.button(l='nmSpc FX Rig >>', h=bh1, c=partial(cGetNmSpc, 'tfNmSpcFX'), bgc=(colBrown[0], colBrown[1], colBrown[2]))
# cmds.textField('tfNmSpcFX', tx='zor_01', bgc=(0,0,0), ed=0)
# cmds.button(l='nmSpc Anim >>', h=bh1, c=partial(cGetNmSpc, 'tfNmSpcAnim'), bgc=(colBlue[0], colBlue[1], colBlue[2]))
# cmds.textField('tfNmSpcAnim', tx='anim', bgc=(0,0,0), ed=0)
# cmds.setParent(top=1)
# visibility
cmds.frameLayout('flBuild', l='BuildSkel', bgc=(colFrameGreen[0], colFrameGreen[1], colFrameGreen[2]), cll=1, cl=0, cc=partial(cShrinkWin, "win_tkVirtualProductionHelper"))
cmds.rowColumnLayout(nc=4, cw = [(1, 105), (2, 105), (3, 105), (4, 105)])
cmds.button(l='Build Skeleton', h=bh1, bgc=(colBrown[0], colBrown[1], colBrown[2]), c=partial(tkTglAll, 'FX'))
cmds.showWindow(myWindow)
cmds.window('win_tkVirtualProductionHelper', e=1, w=300)
tkVirtualProductionHelperUI()
cShrinkWin('win_tkVirtualProductionHelper')