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
|
from ThirdParty.Qt import QtGui, QtCore, QtWidgets
import maya.cmds as cmds
import System.utils as utils
import System.interfaceUtils as interfaceUtils
#maya 2016< maya2017> compatability
try:
import shiboken as shiboken
except:
import shiboken2 as shiboken
def getMainWindow():
import maya.OpenMayaUI as mui
pointer = mui.MQtUtil.mainWindow()
#pyside QMainWindow takes in a QWidget rather than QObject
return shiboken.wrapInstance(long(pointer), QtWidgets.QWidget)
windowTitle = "Set Mirror Module"
windowObject = "pyArtSetMirrorModuleUi"
class ART_SetMirrorModule_UI(QtWidgets.QMainWindow):
def __init__(self, moduleInst, rigUiInst, parent = None):
super(ART_SetMirrorModule_UI, self).__init__(parent)
#get the directory path of the tools
settings = QtCore.QSettings("Epic Games", "ARTv2")
self.toolsPath = settings.value("toolsPath")
self.iconsPath = settings.value("iconPath")
#create class variables
self.modInst = moduleInst
self.rigUiInst = rigUiInst
#load stylesheet
styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
f = open(styleSheetFile, "r")
style = f.read()
f.close()
self.setStyleSheet(style)
#size policies
mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
#create the main widget
self.mainWidget = QtWidgets.QWidget()
self.setCentralWidget(self.mainWidget)
#set qt object name
self.setObjectName(windowObject)
self.setWindowTitle(windowTitle)
#create the mainLayout for the rig creator UI
self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget)
self.mainLayout.setContentsMargins(0, 0, 0, 0)
self.setSizePolicy(mainSizePolicy)
self.setMinimumSize(QtCore.QSize( 250, 200 ))
self.setMaximumSize(QtCore.QSize( 250, 200 ))
#create the background image
self.frame = QtWidgets.QFrame()
self.mainLayout.addWidget(self.frame)
#create the layout for the widgets
self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)
label = QtWidgets.QLabel("Choose Mirror Module:")
self.widgetLayout.addWidget(label)
font = QtGui.QFont()
font.setBold(True)
self.moduleList = QtWidgets.QListWidget()
self.moduleList.addItem("None")
self.widgetLayout.addWidget(self.moduleList)
#add items to comboBox
networkNode = self.modInst.returnNetworkNode
modules = utils.returnRigModules()
for mod in modules:
modName = cmds.getAttr(mod + ".moduleName")
modType = cmds.getAttr(mod + ".moduleType")
if modType == cmds.getAttr(networkNode + ".moduleType"):
if mod != networkNode:
self.moduleList.addItem(modName)
self.moduleList.setCurrentRow(0)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.widgetLayout.addItem(spacerItem1)
#update button
self.updateBtn = QtWidgets.QPushButton("UPDATE")
self.widgetLayout.addWidget(self.updateBtn)
self.updateBtn.setMinimumSize(QtCore.QSize(230, 40))
self.updateBtn.setMaximumSize(QtCore.QSize(230, 40))
self.updateBtn.setSizePolicy(mainSizePolicy)
font = QtGui.QFont()
font.setPointSize(12)
self.updateBtn.setFont(font)
self.updateBtn.setObjectName("blueButton")
#hookup signal/slot on create button
self.updateBtn.clicked.connect(self.setMirrorModule)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setMirrorModule(self):
#get new parent
mirrorModule = self.moduleList.currentItem().text()
#update current parent text
self.modInst.mirrorMod.setText(mirrorModule)
#update network node parentModuleBone attribute
networkNode = self.modInst.returnNetworkNode
cmds.setAttr(networkNode + ".mirrorModule", lock = False)
cmds.setAttr(networkNode + ".mirrorModule", mirrorModule, type = "string", lock = True)
#also do this change to the mirror as well
modules = utils.returnRigModules()
for mod in modules:
modName = cmds.getAttr(mod + ".moduleName")
if modName == mirrorModule:
#set the mirrored version
mirror = cmds.getAttr(networkNode + ".moduleName")
cmds.setAttr(mod + ".mirrorModule", lock = False)
cmds.setAttr(mod + ".mirrorModule", mirror, type = "string", lock = True)
#get instance of mirror module's class
modType = cmds.getAttr(mod + ".moduleType")
modName = cmds.getAttr(mod + ".moduleName")
module = __import__("RigModules." + modType, {}, {}, [modType])
reload(module)
#get the class name from that module file (returns Modules.ART_Root.ART_Root for example)
moduleClass = getattr(module, module.className)
#find the instance of that module and call on the skeletonSettings_UI function
moduleInst = moduleClass(self.rigUiInst, modName)
#update mirrorModtext
#find the current groupBox for this module
for i in range(self.rigUiInst.moduleSettingsLayout.count()):
if type(self.rigUiInst.moduleSettingsLayout.itemAt(i).widget()) == QtWidgets.QGroupBox:
if self.rigUiInst.moduleSettingsLayout.itemAt(i).widget().title() == modName:
self.rigUiInst.moduleSettingsLayout.itemAt(i).widget().setParent(None)
#relaunch the skeleton settings UI with new info
moduleInst.skeletonSettings_UI(modName)
#delete the UI
mayaWindow = interfaceUtils.getMainWindow()
mayaWindow = mayaWindow.objectName()
cmds.deleteUI(mayaWindow + "|" + windowObject)
|