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
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
|
"""
Author: Jeremy Ernst
"""
# import statements
import json
import os
import subprocess
import tempfile
from functools import partial
import System.interfaceUtils as interfaceUtils
import System.utils as utils
import maya.cmds as cmds
from ThirdParty.Qt import QtGui, QtCore, QtWidgets
class ART_ExportMotion(object):
"""
This class is used to export FBX animation from the rig to Unreal Engine. It supports morph targets,
custom attribute curves, and pre/post scripts.
It can be found on the animation sidebar with this icon:
.. image:: /images/exportMotionButton.png
.. todo:: Add the ability to export alembic and animation curve data.
"""
def __init__(self, animPickerUI, parent=None):
"""
Instantiates the class, getting the QSettings and calling on the function to build the interface.
:param animPickerUI: Instance of the Animation UI from which this class was called.
"""
super(ART_ExportMotion, self).__init__()
# get the directory path of the tools
settings = QtCore.QSettings("Epic Games", "ARTv2")
self.toolsPath = settings.value("toolsPath")
self.iconsPath = settings.value("iconPath")
self.scriptPath = settings.value("scriptPath")
self.projectPath = settings.value("projectPath")
self.pickerUI = animPickerUI
# write out qss based on user settings
stylesheetDir = utils.returnNicePath(self.scriptPath, "Interfaces/StyleSheets/")
stylesheets = os.listdir(stylesheetDir)
for sheet in stylesheets:
interfaceUtils.writeQSS(os.path.join(stylesheetDir, sheet))
# build the UI
self.buildUI()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def buildUI(self):
if cmds.window("pyART_ExportMotionWIN", exists=True):
cmds.deleteUI("pyART_ExportMotionWIN", wnd=True)
# create the main window
self.mainWin = QtWidgets.QMainWindow(self.pickerUI)
self.mainWin.resizeEvent = self.windowResized
# create the main widget
self.mainWidget = QtWidgets.QWidget()
self.mainWin.setCentralWidget(self.mainWidget)
# create the mainLayout
self.layout = QtWidgets.QVBoxLayout(self.mainWidget)
# load stylesheet
styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/animPicker.qss")
f = open(styleSheetFile, "r")
self.style = f.read()
f.close()
self.mainWin.setStyleSheet(self.style)
self.mainWin.setMinimumSize(QtCore.QSize(470, 500))
self.mainWin.setMaximumSize(QtCore.QSize(470, 900))
self.mainWin.resize(470, 500)
# set qt object name
self.mainWin.setObjectName("pyART_ExportMotionWIN")
self.mainWin.setWindowTitle("Export Motion")
# tabs
self.exportTabs = QtWidgets.QTabWidget()
self.layout.addWidget(self.exportTabs)
# style sheet
stylesheet = """
QTabBar::tab
{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(19,132,183), stop:1 rgb(30,30,30));
width: 100px;
padding-left: -10px;
}
QTabBar::tab:selected
{
background-color: rgb(14,100,143);
border: 2px solid black;
}
QTabBar::tab:hover
{
background: rgb(19,132,183);
}
QTabBar::tab:!selected
{
margin-top: 5px;
border: 2px solid black;
}
QTabWidget::pane
{
border-top: 2px solid rgb(19,132,183);
border-left: 2px solid rgb(19,132,183);
border-right: 2px solid rgb(19,132,183);
border-bottom: 2px solid rgb(19,132,183);
}
"""
stylesheet2 = """
QTabBar::tab
{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(19,132,183), stop:1 rgb(30,30,30));
width: 140px;
padding-left: -10px;
}
QTabBar::tab:selected
{
background-color: rgb(14,100,143);
border: 2px solid black;
}
QTabBar::tab:hover
{
background: rgb(19,132,183);
}
QTabBar::tab:!selected
{
margin-top: 5px;
}
QTabWidget::pane
{
border-top: 2px solid rgb(255,175,25);
border-left: 0px solid rgb(19,132,183);
border-right: 0px solid rgb(19,132,183);
border-bottom: 2px solid rgb(255,175,25);
}
"""
self.exportTabs.setStyleSheet(stylesheet)
# FBX Tab
self.fbxExportTab = QtWidgets.QWidget()
self.exportTabs.addTab(self.fbxExportTab, "FBX")
# ABC Tab
self.abcExportTab = QtWidgets.QWidget()
self.exportTabs.addTab(self.abcExportTab, "ABC")
# Anim Curve Tab
self.animExportTab = QtWidgets.QWidget()
self.exportTabs.addTab(self.animExportTab, "Animation")
# =======================================================================
# =======================================================================
# =======================================================================
# =======================================================================
# #FBX TAB
# =======================================================================
# =======================================================================
# =======================================================================
# =======================================================================
self.fbxTabLayoutFrame = QtWidgets.QFrame(self.fbxExportTab)
self.fbxTabLayoutFrame.setObjectName("dark")
self.fbxTabLayoutFrame.setMinimumSize(450, 410)
self.fbxTabLayoutFrame.setMaximumSize(450, 900)
self.fbxTabLayoutFrame.setStyleSheet(self.style)
self.fbxTabLayout = QtWidgets.QVBoxLayout(self.fbxTabLayoutFrame)
# FBX Export Tabs
self.fbxTabs = QtWidgets.QTabWidget()
self.fbxTabLayout.addWidget(self.fbxTabs)
self.fbxTabs.setStyleSheet(stylesheet2)
# Settings Tab
self.exportSettings = QtWidgets.QWidget()
self.fbxTabs.addTab(self.exportSettings, "Export Settings")
self.settingsTabLayout = QtWidgets.QVBoxLayout(self.exportSettings)
# Anim Curve Tab
self.sequencesTab = QtWidgets.QWidget()
self.fbxTabs.addTab(self.sequencesTab, "Sequences")
self.sequenceTabLayout = QtWidgets.QVBoxLayout(self.sequencesTab)
# =======================================================================
# =======================================================================
# =======================================================================
# # Export Settings
# =======================================================================
# =======================================================================
# =======================================================================
self.exportSettings = QtWidgets.QFrame()
self.exportSettings.setObjectName("dark")
self.exportSettings.setMinimumSize(QtCore.QSize(415, 330))
self.exportSettings.setMaximumSize(QtCore.QSize(415, 900))
self.settingsTabLayout.addWidget(self.exportSettings)
self.settingsLayout = QtWidgets.QVBoxLayout(self.exportSettings)
# export meshes checkbox
self.exportMeshCB = QtWidgets.QCheckBox("Export Meshes")
self.settingsLayout.addWidget(self.exportMeshCB)
self.exportMeshCB.setChecked(True)
# horizontal layout for morphs and custom attr curves
self.settings_cb_layout = QtWidgets.QHBoxLayout()
self.settingsLayout.addLayout(self.settings_cb_layout)
# export morphs and custom attr curves checkboxes
self.exportMorphsCB = QtWidgets.QCheckBox("Export Morph Targets")
self.settings_cb_layout.addWidget(self.exportMorphsCB)
self.exportMorphsCB.setChecked(True)
self.exportCustomAttrsCB = QtWidgets.QCheckBox("Export Custom Attribute Curves")
self.settings_cb_layout.addWidget(self.exportCustomAttrsCB)
self.exportCustomAttrsCB.setChecked(True)
# horizontal layout for list widgets (morphs and custom attrs)
self.settings_list_layout = QtWidgets.QHBoxLayout()
self.settingsLayout.addLayout(self.settings_list_layout)
# list widgets for listing morphs and custom attr curves
self.exportMorphList = QtWidgets.QListWidget()
self.exportMorphList.setMinimumSize(QtCore.QSize(185, 150))
self.exportMorphList.setMaximumSize(QtCore.QSize(185, 150))
self.settings_list_layout.addWidget(self.exportMorphList)
self.exportMorphList.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
self.exportCurveList = QtWidgets.QListWidget()
self.exportCurveList.setMinimumSize(QtCore.QSize(185, 150))
self.exportCurveList.setMaximumSize(QtCore.QSize(185, 150))
self.settings_list_layout.addWidget(self.exportCurveList)
self.exportCurveList.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
# signal slots for checkboxes and lists
self.exportMorphsCB.stateChanged.connect(partial(self.disableWidget, self.exportMorphList, self.exportMorphsCB))
self.exportCustomAttrsCB.stateChanged.connect(
partial(self.disableWidget, self.exportCurveList, self.exportCustomAttrsCB))
self.exportMorphsCB.stateChanged.connect(self.exportMeshCB.setChecked)
self.exportMeshCB.stateChanged.connect(self.exportMorphsCB.setChecked)
# horizontal layout for pre-script
self.preScript_layout = QtWidgets.QHBoxLayout()
self.settingsLayout.addLayout(self.preScript_layout)
# pre-script checkbox, lineEdit, and button
self.preScriptCB = QtWidgets.QCheckBox("Pre-Script: ")
self.preScript_layout.addWidget(self.preScriptCB)
self.preScript_path = QtWidgets.QLineEdit()
self.preScript_layout.addWidget(self.preScript_path)
ps_browseBtn = QtWidgets.QPushButton()
ps_browseBtn.setMinimumSize(25, 25)
ps_browseBtn.setMaximumSize(25, 25)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/fileBrowse.png"))
ps_browseBtn.setIconSize(QtCore.QSize(25, 25))
ps_browseBtn.setIcon(icon)
ps_browseBtn.clicked.connect(partial(self.fileBrowse_script, self.preScript_path, self.preScriptCB))
self.preScript_layout.addWidget(ps_browseBtn)
# horizontal layout for post-script
self.postScript_layout = QtWidgets.QHBoxLayout()
self.settingsLayout.addLayout(self.postScript_layout)
# pre-script checkbox, lineEdit, and button
self.postScriptCB = QtWidgets.QCheckBox("Post-Script: ")
self.postScript_layout.addWidget(self.postScriptCB)
self.postScript_path = QtWidgets.QLineEdit()
self.postScript_layout.addWidget(self.postScript_path)
pps_browseBtn = QtWidgets.QPushButton()
pps_browseBtn.setMinimumSize(25, 25)
pps_browseBtn.setMaximumSize(25, 25)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/fileBrowse.png"))
pps_browseBtn.setIconSize(QtCore.QSize(25, 25))
pps_browseBtn.setIcon(icon)
pps_browseBtn.clicked.connect(partial(self.fileBrowse_script, self.postScript_path, self.postScriptCB))
self.postScript_layout.addWidget(pps_browseBtn)
# save settings button
button = QtWidgets.QPushButton("Save Export Settings")
self.settingsLayout.addWidget(button)
button.clicked.connect(self.fbx_saveExportData)
# spacer
self.settingsLayout.addSpacerItem(
QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding))
# =======================================================================
# =======================================================================
# =======================================================================
# # FBX Sequences
# =======================================================================
# =======================================================================
# =======================================================================
# # Add Sequence
self.addFbxAnimSequence = QtWidgets.QPushButton("Add Sequence")
self.addFbxAnimSequence.setMinimumSize(QtCore.QSize(415, 50))
self.addFbxAnimSequence.setMaximumSize(QtCore.QSize(415, 50))
self.addFbxAnimSequence.setObjectName("blueButton")
self.addFbxAnimSequence.clicked.connect(partial(self.fbx_addSequence))
self.sequenceTabLayout.addWidget(self.addFbxAnimSequence)
# #Main Export Section
self.fbxAnimSequenceFrame = QtWidgets.QFrame()
self.fbxAnimSequenceFrame.setMinimumWidth(415)
self.fbxAnimSequenceFrame.setMaximumWidth(415)
scrollSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)
self.fbxAnimSequenceFrame.setSizePolicy(scrollSizePolicy)
self.fbxAnimSequenceFrame.setObjectName("dark")
self.fbxMainScroll = QtWidgets.QScrollArea()
self.sequenceTabLayout.addWidget(self.fbxMainScroll)
self.fbxMainScroll.setMinimumSize(QtCore.QSize(415, 280))
self.fbxMainScroll.setMaximumSize(QtCore.QSize(415, 900))
self.fbxMainScroll.setWidgetResizable(True)
self.fbxMainScroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.fbxMainScroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.fbxMainScroll.setWidget(self.fbxAnimSequenceFrame)
self.fbxSequenceLayout = QtWidgets.QVBoxLayout(self.fbxAnimSequenceFrame)
self.fbxSequenceLayout.addSpacerItem(
QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding))
# spacer
self.sequenceTabLayout.addSpacerItem(
QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding))
# =======================================================================
# #export button
# =======================================================================
self.doFbxExportBtn = QtWidgets.QPushButton("Export")
self.fbxTabLayout.addWidget(self.doFbxExportBtn)
self.doFbxExportBtn.setObjectName("blueButton")
self.doFbxExportBtn.setMinimumSize(QtCore.QSize(430, 40))
self.doFbxExportBtn.setMaximumSize(QtCore.QSize(430, 40))
self.doFbxExportBtn.clicked.connect(self.fbx_export)
# show window
self.mainWin.show()
self.fbxTabs.setCurrentIndex(1)
# find morphs
self.findMorphs()
# find custom curves
self.findCustomCurves()
# populate UI
self.fbx_populateUI()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_checkExportMesh(self):
if self.exportMorphsCB.isChecked():
if not self.exportMeshCB.isChecked():
self.exportMeshCB.setChecked(True)
self.exportMeshCB.setEnabled(False)
else:
self.exportMeshCB.setEnabled(True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_populateUI(self, refresh=False, *args):
# remove existing animation sequences
widgetsToRemove = []
for i in range(self.fbxSequenceLayout.count()):
child = self.fbxSequenceLayout.itemAt(i)
if child is not None:
if type(child.widget()) == QtWidgets.QGroupBox:
widgetsToRemove.append(child.widget())
for widget in widgetsToRemove:
self.fbx_removeAnimSequence(widget)
# get characters in scene
characters = []
characterInfo = self.findCharacters()
for info in characterInfo:
characters.append(info[0])
# check character nodes for fbxAnimData
for currentChar in characters:
# loop through data, adding sequences and setting settings
if cmds.objExists(currentChar + ":ART_RIG_ROOT.fbxAnimData"):
fbxData = json.loads(cmds.getAttr(currentChar + ":ART_RIG_ROOT.fbxAnimData"))
# each entry in the fbxData list is a sequence with all the needed information
for data in fbxData:
# first, set export settings
self.exportMeshCB.setChecked(data[0])
self.exportMorphsCB.setChecked(data[1])
self.exportCustomAttrsCB.setChecked(data[2])
# select morphs and curves to export in the lists if they exist
for i in range(self.exportMorphList.count()):
bShape = self.exportMorphList.item(i)
text = bShape.text()
if text in data[3]:
bShape.setSelected(True)
for i in range(self.exportCurveList.count()):
cCurve = self.exportCurveList.item(i)
text = cCurve.text()
if text in data[4]:
cCurve.setSelected(True)
# set pre/post script info
self.preScriptCB.setChecked(data[5][0])
self.preScript_path.setText(data[5][1])
self.postScriptCB.setChecked(data[6][0])
self.postScript_path.setText(data[6][1])
# add anim sequence
self.fbx_addSequence(data[7])
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_addSequence(self, data=None):
# get number of children of fbxSequenceLayout
children = self.fbxSequenceLayout.count()
index = children - 1
# contained groupBox for each sequence
groupBox = QtWidgets.QGroupBox()
groupBox.setCheckable(True)
groupBox.setMaximumHeight(260)
groupBox.setMaximumWidth(380)
self.fbxSequenceLayout.insertWidget(index, groupBox)
# set context menu policy on groupbox
groupBox.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
groupBox.customContextMenuRequested.connect(partial(self.fbx_createContextMenu, groupBox))
# add frame layout to groupbox
frameLayout = QtWidgets.QVBoxLayout(groupBox)
# add frame to groupbox
frame = QtWidgets.QFrame()
frame.setObjectName("light")
frameLayout.addWidget(frame)
vLayout = QtWidgets.QVBoxLayout(frame)
vLayout.setObjectName("vLayout")
# signal slot for groupbox checkbox
QtCore.QObject.connect(groupBox, QtCore.SIGNAL("toggled(bool)"), frame.setVisible)
groupBox.setChecked(True)
# =======================================================================
# #portrait and character combo box
# =======================================================================
characterLayout = QtWidgets.QHBoxLayout()
characterLayout.setObjectName("charLayout")
vLayout.addLayout(characterLayout)
portrait = QtWidgets.QLabel()
portrait.setObjectName("charPortrait")
portrait.setMinimumSize(QtCore.QSize(30, 30))
portrait.setMaximumSize(QtCore.QSize(30, 30))
characterLayout.addWidget(portrait)
characterComboBox = QtWidgets.QComboBox()
characterComboBox.setObjectName("charComboBox")
characterComboBox.setMinimumHeight(30)
characterComboBox.setMaximumHeight(30)
characterLayout.addWidget(characterComboBox)
# populate combo box
characters = self.findCharacters()
for character in characters:
characterName = character[0]
characterComboBox.addItem(characterName)
self.updateIcon(characterComboBox, portrait, characters)
characterComboBox.currentIndexChanged.connect(partial(self.updateIcon, characterComboBox, portrait, characters))
# =======================================================================
# #Checkbox, path, and browse button
# =======================================================================
pathLayout = QtWidgets.QHBoxLayout()
pathLayout.setObjectName("pathLayout")
vLayout.addLayout(pathLayout)
checkBox = QtWidgets.QCheckBox()
checkBox.setObjectName("exportCheckBox")
checkBox.setChecked(True)
pathLayout.addWidget(checkBox)
pathField = QtWidgets.QLineEdit()
pathField.setObjectName("exportPath")
pathLayout.addWidget(pathField)
pathField.setMinimumWidth(200)
browseBtn = QtWidgets.QPushButton()
browseBtn.setMinimumSize(25, 25)
browseBtn.setMaximumSize(25, 25)
pathLayout.addWidget(browseBtn)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/fileBrowse.png"))
browseBtn.setIconSize(QtCore.QSize(25, 25))
browseBtn.setIcon(icon)
browseBtn.clicked.connect(partial(self.fileBrowse_export, pathField))
# =======================================================================
# #frame range, and frame rate
# =======================================================================
optionLayout = QtWidgets.QHBoxLayout()
vLayout.addLayout(optionLayout)
optionLayout.setObjectName("optionLayout")
label1 = QtWidgets.QLabel("Start Frame: ")
optionLayout.addWidget(label1)
label1.setStyleSheet("background: transparent;")
startFrame = QtWidgets.QSpinBox()
startFrame.setObjectName("startFrame")
optionLayout.addWidget(startFrame)
startFrame.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
startFrame.setRange(-1000, 10000)
label2 = QtWidgets.QLabel(" End Frame: ")
optionLayout.addWidget(label2)
label2.setStyleSheet("background: transparent;")
label2.setAlignment(QtCore.Qt.AlignCenter)
endFrame = QtWidgets.QSpinBox()
endFrame.setObjectName("endFrame")
optionLayout.addWidget(endFrame)
endFrame.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
endFrame.setRange(-1000, 10000)
# set frame range by default based on current timeline
start = cmds.playbackOptions(q=True, ast=True)
end = cmds.playbackOptions(q=True, aet=True)
startFrame.setValue(start)
endFrame.setValue(end)
frameRate = QtWidgets.QComboBox()
frameRate.setObjectName("frameRate")
optionLayout.addWidget(frameRate)
frameRate.hide()
# add items to frame rate
frameRate.addItem("ntsc")
frameRate.addItem("ntscf")
frameRate.addItem("film")
# set the FPS to the current scene setting
fps = cmds.currentUnit(q=True, time=True)
if fps == "film":
frameRate.setCurrentIndex(2)
if fps == "ntsc":
frameRate.setCurrentIndex(0)
if fps == "ntscf":
frameRate.setCurrentIndex(1)
# =======================================================================
# #advanced options
# =======================================================================
advancedGroup = QtWidgets.QGroupBox("Advanced Settings")
vLayout.addWidget(advancedGroup)
advancedGroup.setCheckable(True)
advancedLayout = QtWidgets.QVBoxLayout(advancedGroup)
advancedFrame = QtWidgets.QFrame()
advancedLayout.addWidget(advancedFrame)
advancedFrameLayout = QtWidgets.QVBoxLayout(advancedFrame)
# =======================================================================
# #rotation interpolation
# =======================================================================
interpLayout = QtWidgets.QHBoxLayout()
advancedFrameLayout.addLayout(interpLayout)
label3 = QtWidgets.QLabel("Rotation Interpolation: ")
interpLayout.addWidget(label3)
label3.setStyleSheet("background: transparent;")
interpCombo = QtWidgets.QComboBox()
interpLayout.addWidget(interpCombo)
interpCombo.setObjectName("rotInterp")
interpCombo.setMinimumWidth(150)
interpCombo.addItem("Quaternion Slerp")
interpCombo.addItem("Independent Euler-Angle")
# =======================================================================
# #sample rate and root options
# =======================================================================
rateRootLayout = QtWidgets.QHBoxLayout()
advancedFrameLayout.addLayout(rateRootLayout)
label4 = QtWidgets.QLabel("Sample Rate: ")
rateRootLayout.addWidget(label4)
sampleRate = QtWidgets.QDoubleSpinBox()
sampleRate.setObjectName("sampleRate")
rateRootLayout.addWidget(sampleRate)
sampleRate.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
sampleRate.setRange(0, 1)
sampleRate.setSingleStep(0.1)
sampleRate.setValue(1.00)
rootComboBox = QtWidgets.QComboBox()
rootComboBox.setObjectName("rootExportOptions")
rootComboBox.addItem("Export Root Animation")
rootComboBox.addItem("Zero Root")
rootComboBox.addItem("Zero Root, Keep World Space")
rateRootLayout.addWidget(rootComboBox)
# signal slot for groupbox checkbox
QtCore.QObject.connect(advancedGroup, QtCore.SIGNAL("toggled(bool)"), advancedFrame.setVisible)
advancedGroup.setChecked(False)
# signal slot for groupbox title
characterComboBox.currentIndexChanged.connect(partial(self.fbx_updateTitle, groupBox))
pathField.textChanged.connect(partial(self.fbx_updateTitle, groupBox))
startFrame.valueChanged.connect(partial(self.fbx_updateTitle, groupBox))
endFrame.valueChanged.connect(partial(self.fbx_updateTitle, groupBox))
checkBox.stateChanged.connect(partial(self.fbx_updateTitle, groupBox))
# create groupbox title
self.fbx_updateTitle(groupBox)
# set data if coming from duplicate call
if data:
# set character combo box
for i in range(characterComboBox.count()):
text = characterComboBox.itemText(i)
if text == data[0]:
characterComboBox.setCurrentIndex(i)
# set export checkbox
checkBox.setChecked(data[1])
# set export path
pathField.setText(data[2])
# set start frame
startFrame.setValue(data[3])
# set end frame
endFrame.setValue(data[4])
# set FPS
for i in range(frameRate.count()):
text = frameRate.itemText(i)
if text == data[5]:
frameRate.setCurrentIndex(i)
# set rotation interpolation
for i in range(interpCombo.count()):
text = interpCombo.itemText(i)
if text == data[6]:
interpCombo.setCurrentIndex(i)
# set sample rate
sampleRate.setValue(data[7])
# set root export
for i in range(rootComboBox.count()):
text = rootComboBox.itemText(i)
if text == data[8]:
rootComboBox.setCurrentIndex(i)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_createContextMenu(self, widget, point):
# icons
icon_delete = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/delete.png"))
icon_duplicate = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/duplicate.png"))
icon_collapse = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/upArrow.png"))
icon_expand = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/downArrow.png"))
# create the context menu
contextMenu = QtWidgets.QMenu()
contextMenu.addAction(icon_delete, "Remove Sequence", partial(self.fbx_removeAnimSequence, widget))
contextMenu.addAction(icon_duplicate, "Duplicate Sequence", partial(self.fbx_duplicateSequence, widget))
contextMenu.addAction(icon_expand, "Expand All Sequences", partial(self.fbx_expandAllSequences, True))
contextMenu.addAction(icon_collapse, "Collapse All Sequences", partial(self.fbx_expandAllSequences, False))
contextMenu.exec_(widget.mapToGlobal(point))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_removeAnimSequence(self, widget):
widget.setParent(None)
widget.close()
self.fbx_saveExportData()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_duplicateSequence(self, widget):
sequenceData = self.fbx_getSequenceInfo(widget)
self.fbx_addSequence(sequenceData)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fileBrowse_export(self, widget):
try:
path = cmds.fileDialog2(fm=0, okc="Export", dir=self.projectPath, ff="*.fbx")
nicePath = utils.returnFriendlyPath(path[0])
widget.setText(nicePath)
except:
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fileBrowse_script(self, widget, checkbox=None):
try:
path = cmds.fileDialog2(fm=1, okc="Accept", dir=self.projectPath, ff="*.py;;*.mel")
nicePath = utils.returnFriendlyPath(path[0])
widget.setText(nicePath)
if checkbox is not None:
checkbox.setChecked(True)
except:
pass
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_export(self):
# save settings
characterData = self.fbx_saveExportData()
# find mayapy interpreter location
mayapy = utils.getMayaPyLoc()
# message box for confirming save action
msgBax = QtWidgets.QMessageBox()
msgBax.setText("Please make sure any changes to the current file are saved before continuing.\
This process will be creating a temporary file to do all of the exporting from.")
msgBax.setIcon(QtWidgets.QMessageBox.Warning)
msgBax.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
msgBax.setDefaultButton(QtWidgets.QMessageBox.Ok)
ret = msgBax.exec_()
if ret == QtWidgets.QMessageBox.Ok:
# save copy of scene to temp location
sourceFile = cmds.file(q=True, sceneName=True)
filePath = os.path.dirname(sourceFile)
tempFile = os.path.join(filePath, "export_TEMP.ma")
cmds.file(rename=tempFile)
cmds.file(save=True, type="mayaAscii", force=True)
# pass tempFile and characterData to mayapy instance for processing
if os.path.exists(mayapy):
script = utils.returnFriendlyPath(os.path.join(self.toolsPath, "Core\Scripts\System\ART_FbxExport.py"))
# create a temp file with the json data
with tempfile.NamedTemporaryFile(delete=False) as temp:
json.dump(characterData, temp)
temp.close()
# create a log file
stdoutFile = os.path.join(filePath, "export_log.txt")
out = file(stdoutFile, 'w')
# open mayapy, passing in export file and character data
subprocess.Popen(mayapy + ' ' + "\"" + script + "\"" + ' ' + "\"" + tempFile + "\"" + ' ' +
"\"" + temp.name + "\"", stdout=out, stderr=out)
# close the output file (for logging)
out.close()
else:
msgBox = QtWidgets.QMessageBox()
msgBox.setText("mayapy executable not found. Currently not implemented for mac and linux.")
msgBox.setIcon(QtWidgets.QMessageBox.Error)
msgBox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
msgBox.setDefaultButton(QtWidgets.QMessageBox.Ok)
msgBox.exec_()
# reopen the original file
cmds.file(sourceFile, open=True, force=True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def findMorphs(self):
# clear list
self.exportMorphList.clear()
characterMeshes = []
# get all characters
characters = self.findCharacters()
for character in characters:
currentCharacter = character[0]
# get meshes off of character node
if cmds.objExists(currentCharacter + ":ART_RIG_ROOT"):
if cmds.objExists(currentCharacter + ":ART_RIG_ROOT.LOD_0_Meshes"):
characterMeshes = cmds.listConnections(currentCharacter + ":ART_RIG_ROOT.LOD_0_Meshes")
# get skinClusters in scene and query their connections
skins = cmds.ls(type="skinCluster")
for skin in skins:
shapeInfo = cmds.listConnections(skin, c=True, type="blendShape", et=True)
mesh = cmds.listConnections(skin, type="mesh")
if mesh is not None:
# confirm that the blendshape found belongs to one of our character meshes. Then add to list
if mesh[0] in characterMeshes:
if shapeInfo is not None:
for info in shapeInfo:
if cmds.nodeType(info) == "blendShape":
item = QtWidgets.QListWidgetItem(info)
self.exportMorphList.addItem(item)
item.setSelected(False)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def findCustomCurves(self):
# get all characters
characters = self.findCharacters()
for character in characters:
currentCharacter = character[0]
rootBone = currentCharacter + ":root"
attrs = cmds.listAttr(rootBone, keyable=True)
standardAttrs = ["translateX", "translateY", "translateZ", "rotateX", "rotateY", "rotateZ",
"scaleX", "scaleY", "scaleZ", "visibility"]
for attr in attrs:
if attr not in standardAttrs:
item = QtWidgets.QListWidgetItem(currentCharacter + ":" + attr)
self.exportCurveList.addItem(item)
item.setSelected(False)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def findCharacters(self):
characterInfo = []
allNodes = cmds.ls(type="network")
characterNodes = []
for node in allNodes:
attrs = cmds.listAttr(node)
if "rigModules" in attrs:
characterNodes.append(node)
# go through each node, find the character name, the namespace on the node, and the picker attribute
for node in characterNodes:
try:
namespace = cmds.getAttr(node + ".namespace")
except:
namespace = cmds.getAttr(node + ".name")
# add the icon found on the node's icon path attribute to the tab
iconPath = cmds.getAttr(node + ".iconPath")
iconPath = utils.returnNicePath(self.projectPath, iconPath)
characterInfo.append([namespace, iconPath])
return characterInfo
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def updateIcon(self, comboBox, label, characterInfo, *args):
# get current selection of combo box
characterName = comboBox.currentText()
# loop through characterInfo, find matching characterName, and get icon path
for each in characterInfo:
if characterName == each[0]:
iconPath = each[1]
img = QtGui.QImage(iconPath)
pixmap = QtGui.QPixmap(img.scaledToWidth(30))
label.setPixmap(pixmap)
label.show()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def windowResized(self, event):
currentSize = self.mainWin.size()
height = currentSize.height()
self.fbxTabLayoutFrame.resize(450, height - 50)
width = self.fbxTabs.size()
width = width.width()
self.fbxTabs.resize(width, height - 50)
self.fbxMainScroll.setMinimumSize(415, height - 220)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def disableWidget(self, widget, checkbox, *args):
state = checkbox.isChecked()
if state:
widget.setEnabled(True)
for i in range(widget.count()):
item = widget.item(i)
item.setHidden(False)
else:
widget.setEnabled(False)
for i in range(widget.count()):
item = widget.item(i)
item.setHidden(True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_updateTitle(self, groupBox, *args):
# get info from interface
data = []
children = groupBox.children()
for each in children:
if type(each) == QtWidgets.QFrame:
contents = each.children()
for child in contents:
objectName = child.objectName()
if objectName == "charComboBox":
char = child.currentText()
data.append(char)
if objectName == "exportCheckBox":
value = child.isChecked()
data.append(value)
if objectName == "exportPath":
path = child.text()
filename = os.path.basename(path)
data.append(filename.partition(".")[0])
if objectName == "startFrame":
startFrame = child.value()
data.append(startFrame)
if objectName == "endFrame":
endFrame = child.value()
data.append(endFrame)
titleString = ""
if data[1]:
titleString += data[0] + ", "
titleString += data[2] + ", "
titleString += "["
titleString += str(data[3]) + ": "
titleString += str(data[4]) + "]"
else:
titleString += "Not Exporting.."
groupBox.setTitle(titleString)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_saveExportData(self):
exportData = []
# get main export settings
exportMesh = self.exportMeshCB.isChecked()
exportMorph = self.exportMorphsCB.isChecked()
exportCurve = self.exportCustomAttrsCB.isChecked()
exportData.append(exportMesh)
exportData.append(exportMorph)
exportData.append(exportCurve)
# get selected morphs
morphs = []
for i in range(self.exportMorphList.count()):
item = self.exportMorphList.item(i)
if item.isSelected():
morphs.append(item.text())
# get selected curves
curves = []
for i in range(self.exportCurveList.count()):
item = self.exportCurveList.item(i)
if item.isSelected():
curves.append(item.text())
# pre and post script
preScript = self.preScriptCB.isChecked()
preScript_path = self.preScript_path.text()
postScript = self.postScriptCB.isChecked()
postScript_path = self.postScript_path.text()
exportData.append(morphs)
exportData.append(curves)
exportData.append([preScript, preScript_path])
exportData.append([postScript, postScript_path])
# get fbx sequences and settings
characterData = {}
for i in range(self.fbxSequenceLayout.count()):
child = self.fbxSequenceLayout.itemAt(i)
if type(child.widget()) == QtWidgets.QGroupBox:
data = []
sequenceData = self.fbx_getSequenceInfo(child.widget())
data.extend(exportData)
data.append(sequenceData)
if sequenceData[0] not in characterData:
characterData[sequenceData[0]] = [data]
else:
currentData = characterData.get(sequenceData[0])
currentData.append(data)
characterData[sequenceData[0]] = currentData
# loop through each key (character) in the dictionary, and write its data to the network node
for each in characterData:
data = characterData.get(each)
# Add that data to the character node
networkNode = each + ":ART_RIG_ROOT"
if not cmds.objExists(networkNode + ".fbxAnimData"):
cmds.addAttr(networkNode, ln="fbxAnimData", dt="string")
cmds.setAttr(networkNode + ".fbxAnimData", json.dumps(data), type="string")
return characterData
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_getSequenceInfo(self, groupBox, *args):
# get info from interface
data = []
children = groupBox.children()
for each in children:
if type(each) == QtWidgets.QFrame:
contents = each.children()
for child in contents:
objectName = child.objectName()
if objectName == "charComboBox":
char = child.currentText()
data.append(char)
if objectName == "exportCheckBox":
value = child.isChecked()
data.append(value)
if objectName == "exportPath":
path = child.text()
data.append(path)
if objectName == "startFrame":
startFrame = child.value()
data.append(startFrame)
if objectName == "endFrame":
endFrame = child.value()
data.append(endFrame)
if objectName == "frameRate":
fps = child.currentText()
data.append(fps)
if type(child) == QtWidgets.QGroupBox:
subChildren = child.children()
for sub in subChildren:
if type(sub) == QtWidgets.QFrame:
advancedChildren = sub.children()
for advancedChild in advancedChildren:
advancedObj = advancedChild.objectName()
if advancedObj == "sampleRate":
rate = advancedChild.value()
data.append(rate)
if advancedObj == "rotInterp":
interp = advancedChild.currentText()
data.append(interp)
if advancedObj == "rootExportOptions":
root = advancedChild.currentText()
data.append(root)
return data
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def fbx_expandAllSequences(self, state):
# get info from interface
for i in range(self.fbxSequenceLayout.count()):
data = []
child = self.fbxSequenceLayout.itemAt(i)
if type(child.widget()) == QtWidgets.QGroupBox:
child.widget().setChecked(state)
|