Example #1
0
    def __init__(self, x, y, w, h, scene, view, animUI):

        super(commentBoxItem, self).__init__(x, y, w, h)

        self.brush = QtGui.QBrush(QtGui.QColor(60, 60, 60, 125))
        self.brushColor = self.brush.color()
        self.width = w
        self.height = h
        self.x = x
        self.y = y
        self.scale = 1
        self.menu = QtWidgets.QMenu()
        self.scene = scene
        self.view = view
        self.animUI = animUI

        self.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges)

        # add items to context menu
        self.menu.addAction("Change Color", self.changeBoxColor)
        self.menu.addAction("Rename", self.changeLabelText)
        self.menu.addAction("Remove Comment Box", self.deleteCommentBox)

        # add text
        self.textLabel = QtWidgets.QGraphicsTextItem("Comment Box", self, scene)
        self.textLabel.setPos(x, y - 20)
        self.textLabel.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
        # self.textLabel.setTextInteractionFlags(QtCore.Qt.TextEditable)

        self.classType = "comment"
Example #2
0
def gitCredsUI(parent):
    """
    Create an interface that allows user to enter github username and password.

    :param parent: interface that this interface will be a child of.
    """

    credsDialog = QtWidgets.QDialog(parent)
    credsDialog.setWindowTitle("Github Credentials")
    credsDialog.setMinimumSize(QtCore.QSize(200, 120))
    credsDialog.setMaximumSize(QtCore.QSize(200, 120))

    layout = QtWidgets.QVBoxLayout(credsDialog)
    userName = QtWidgets.QLineEdit()
    userName.setPlaceholderText("Github User Name..")
    layout.addWidget(userName)

    password = QtWidgets.QLineEdit()
    password.setPlaceholderText("Github Password..")
    layout.addWidget(password)
    password.setEchoMode(QtWidgets.QLineEdit.Password)

    confirmButton = QtWidgets.QPushButton("Confirm")
    layout.addWidget(confirmButton)
    confirmButton.setObjectName("blueButton")
    confirmButton.clicked.connect(
        partial(gitWriteCreds, userName, password, credsDialog))

    credsDialog.exec_()
Example #3
0
    def setBoneCountTarget(self):
        """
        Builds a UI that allows the user to set the target bone count.

            .. image:: /images/boneCountTarget.png

        """

        # launch a UI to get the name information
        self.targetWindow = QtWidgets.QMainWindow()

        # size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        # create the main widget
        self.targetWindow_mainWidget = QtWidgets.QWidget()
        self.targetWindow.setCentralWidget(self.targetWindow_mainWidget)

        # set qt object name
        self.targetWindow.setObjectName("ART_setBoneCountTarget_UI")
        self.targetWindow.setWindowTitle("Bone Count")

        # create the mainLayout for the rig creator UI
        self.targetWindow_topLayout = QtWidgets.QVBoxLayout(self.targetWindow_mainWidget)
        self.targetWindow_mainLayout = QtWidgets.QFormLayout()
        self.targetWindow_topLayout.addLayout(self.targetWindow_mainLayout)

        self.targetWindow_topLayout.setContentsMargins(10, 10, 10, 10)
        self.targetWindow.resize(250, 70)
        self.targetWindow.setSizePolicy(mainSizePolicy)
        self.targetWindow.setMinimumSize(QtCore.QSize(250, 70))
        self.targetWindow.setMaximumSize(QtCore.QSize(250, 70))

        # add label
        label = QtWidgets.QLabel("Enter a target bone count:        ")
        self.targetWindow_mainLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, label)

        # add spinBox
        self.targetWindow_SpinBox = QtWidgets.QSpinBox()
        self.targetWindow_SpinBox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.targetWindow_SpinBox.setRange(1, 9999)
        self.targetWindow_SpinBox.setMinimumWidth(70)
        self.targetWindow_SpinBox.setStyleSheet("background-color: rgb(255,255,255); color: rgb(0,0,0);")
        self.targetWindow_mainLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.targetWindow_SpinBox)
        self.targetWindow_SpinBox.setValue(100)
        self.targetWindow_SpinBox.setObjectName("ART_targetWindowSpinBox")

        # add a confirm button
        self.targetWindow_confirmButton = QtWidgets.QPushButton("Confirm")
        self.targetWindow_topLayout.addWidget(self.targetWindow_confirmButton)

        buttonImage = utils.returnNicePath(self.iconsPath, "System/blue_field_background.png")
        self.targetWindow_confirmButton.setStyleSheet(
            "background-image: url(" + buttonImage + "); background-color: rgb(0,0,0);")
        self.targetWindow_confirmButton.clicked.connect(self.setBoneCountTarget_Confirm)

        # show the window
        self.targetWindow.show()
Example #4
0
    def findCharacterModules(self, *args):

        if self.showUI:
            self.moduleList.clear()

            # current character
            selectedChar = self.characterCombo.currentText()

            # get rig modules
            if cmds.objExists(selectedChar + ":" + "ART_RIG_ROOT"):
                modules = cmds.listConnections(selectedChar + ":" +
                                               "ART_RIG_ROOT.rigModules")

                for module in modules:
                    modName = cmds.getAttr(module + ".moduleName")
                    item = QtWidgets.QListWidgetItem(modName)
                    item.setData(QtCore.Qt.UserRole, module)
                    self.moduleList.addItem(item)

        else:
            index = self.pickerUI.characterTabs.currentIndex()
            selectedChar = self.pickerUI.characterTabs.tabToolTip(index)

            if cmds.objExists(selectedChar + ":" + "ART_RIG_ROOT"):
                modules = cmds.listConnections(selectedChar + ":" +
                                               "ART_RIG_ROOT.rigModules")

            return modules
    def addModulesToList(self):

        #get the current tab index and the widget
        index = self.pickerUI.characterTabs.currentIndex()
        character = self.pickerUI.characterTabs.tabToolTip(index)

        #find character nodes in the scene, and compare namespace to selected tab
        characterMods = utils.returnCharacterModules()
        nodeNamespace = ""

        for each in characterMods:
            if cmds.objExists(each + ".namespace"):
                namespace = cmds.getAttr(each + ".namespace")
                if namespace == character:
                    nodeNamespace = namespace + ":"

        for module in self.modulesToAdd:
            info = self.getCurrentCanvasTab(module)
            if info[1] != None:
                modName = cmds.getAttr(nodeNamespace + module + ".moduleName")

                #add to listWIdget
                item = QtWidgets.QListWidgetItem(modName)
                item.setData(QtCore.Qt.UserRole, module)
                self.moduleList.addItem(item)
Example #6
0
    def skeletonSettings_UI(self, name):
        #groupbox all modules get
        ART_RigModule.skeletonSettings_UI(self, name, 335, 85, False)

        #add a label to the root module saying this module cannot be edited or removed
        self.layout = QtWidgets.QVBoxLayout(self.groupBox)
        self.label = QtWidgets.QLabel(
            "All rigs must have a root module. This module cannot be edited or removed."
        )
        self.layout.addWidget(self.label)
        self.label.setGeometry(QtCore.QRect(10, 20, 300, 60))
        self.label.setMinimumHeight(60)
        self.label.setWordWrap(True)

        #add to the rig cretor UI's module settings layout VBoxLayout
        self.rigUiInst.moduleSettingsLayout.addWidget(self.groupBox)
Example #7
0
    def checkForCustomMeshes(self):

        #check for custom geometry
        skinnableGeo = self.findCustomGeo()
        meshes = list(skinnableGeo)

        if len(skinnableGeo) > 0:

            matches = []

            #check to see if weight files exist for this geo on disk
            for i in range(len(meshes)):
                filePath = utils.returnFriendlyPath(
                    os.path.join(cmds.internalVar(utd=True),
                                 meshes[i] + ".WEIGHTS"))
                if os.path.exists(filePath):
                    matches.append(meshes[i])

            if len(matches) > 0:
                for match in matches:
                    listWidgetItem = QtWidgets.QListWidgetItem(match)
                    self.page5MeshList.addItem(listWidgetItem)
                    listWidgetItem.setSelected(True)

                #go to page 5
                self.stackWidget.setCurrentIndex(4)

            else:
                #go to page 3
                self.stackWidget.setCurrentIndex(2)

        else:
            #go to page 2
            self.stackWidget.setCurrentIndex(1)
Example #8
0
    def populateCharacters(self):
        """
        Given the selected project and group, populate the QListWidget with any assets found using that information.
        The project path comes from the QSettings, the group is a subfolder of the project.

        """

        # add project button
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)

        # get a list of the existing folders in projects
        selectedProject = self.projectMenu.currentText()
        fullPath = os.path.join(self.projectPath, selectedProject)
        selectedGroup = self.groupMenu.currentText()
        if len(selectedGroup) > 1:
            fullPath = os.path.join(fullPath, selectedGroup)

        existingCharacters = os.listdir(fullPath)
        files = []

        # find out which returned items are directories
        for each in existingCharacters:
            if os.path.isfile(os.path.join(fullPath, each)):
                if each.rpartition(".")[2] == "ma":
                    files.append(each)

        # otherwise, add each project to the combo box
        self.characterList.clear()

        for each in files:
            item = QtWidgets.QListWidgetItem(each.partition(".ma")[0])
            item.setFont(font)
            self.characterList.addItem(item)
Example #9
0
    def loadSettings(self):

        #open a file browser dialog for user to name file
        dialog = QtWidgets.QFileDialog(
            None, "Open",
            os.path.join(self.toolsPath,
                         "settings" + os.sep + "importSettings"))
        dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
        dialog.setDefaultSuffix("json")
        dialog.exec_()
        fileName = dialog.selectedFiles()

        #open and read the file
        f = open(fileName[0], 'r')
        data = json.load(f)
        f.close()

        #find items in UI
        modules = {}
        for i in range(self.fbxModuleList.count()):
            item = self.fbxModuleList.item(i)
            itemWidget = self.fbxModuleList.itemWidget(item)
            itemModule = itemWidget.property("module")

            children = itemWidget.children()
            for child in children:
                if type(child) == QtWidgets.QComboBox:
                    modules[itemModule] = child

        #loop through data
        keys = modules.keys()
        for each in data:
            if each[0] in keys:
                comboBox = modules.get(each[0])
                comboBox.setCurrentIndex(each[1])
Example #10
0
    def findCharacterModules(self, *args):

        self.moduleList.clear()

        # current character
        selectedChar = self.characterCombo.currentText()

        # get rig modules
        if cmds.objExists(selectedChar + ":" + "ART_RIG_ROOT"):
            modules = cmds.listConnections(selectedChar + ":" +
                                           "ART_RIG_ROOT.rigModules")

            for module in modules:
                niceName = cmds.getAttr(module + ".moduleName")
                moduleType = cmds.getAttr(module + ".moduleType")

                # create widget
                item = QtWidgets.QListWidgetItem()

                widgetItem = QtWidgets.QGroupBox()
                widgetItem.setMinimumHeight(50)
                widgetItem.setProperty("module", module)
                widgetItem.setObjectName("light")

                layout = QtWidgets.QHBoxLayout(widgetItem)

                checkBox = QtWidgets.QCheckBox(niceName)
                checkBox.setChecked(False)
                layout.addWidget(checkBox)

                comboBox = QtWidgets.QComboBox()
                layout.addWidget(comboBox)

                # add items to combo box bases on module class var
                mod = __import__("RigModules." + moduleType, {}, {},
                                 [moduleType])
                matchData = mod.matchData

                if matchData[0] is True:
                    for each in matchData[1]:
                        comboBox.addItem(each)

                    comboBox.setCurrentIndex(1)

                    self.moduleList.addItem(item)
                    self.moduleList.setItemWidget(item, widgetItem)
Example #11
0
    def buildUI(self):
        #Original Author: Jeremy Ernst

        #create the main window
        self.mainWin = QtWidgets.QMainWindow(self.mainUI)
        self.mainWin.setStyleSheet(
            "background-color: rgb(0, 0, 0);, color: rgb(0,0,0);")

        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.mainWin.setStyleSheet(self.style)

        #create the main widget
        self.mainWidget = QtWidgets.QWidget()
        self.mainWin.setCentralWidget(self.mainWidget)

        #set qt object name
        self.mainWin.setObjectName("ART_RigHistWin")
        self.mainWin.setWindowTitle("Rig History")

        #font
        headerFont = QtGui.QFont()
        headerFont.setPointSize(8)
        headerFont.setBold(True)

        #set size policy
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        #create the mainLayout for the rig creator UI
        self.layout = QtWidgets.QVBoxLayout(self.mainWidget)

        self.mainWin.resize(400, 240)
        self.mainWin.setSizePolicy(mainSizePolicy)
        self.mainWin.setMinimumSize(QtCore.QSize(400, 240))
        self.mainWin.setMaximumSize(QtCore.QSize(400, 240))

        #create the QFrame for this page
        self.background = QtWidgets.QFrame()
        self.layout.addWidget(self.background)
        self.mainLayout = QtWidgets.QVBoxLayout(self.background)
        self.background.setObjectName("epic")

        #detailed information
        self.infoText = QtWidgets.QTextEdit()
        self.mainLayout.addWidget(self.infoText)
        self.infoText.setMinimumSize(QtCore.QSize(360, 200))
        self.infoText.setMaximumSize(QtCore.QSize(360, 200))
        self.infoText.setReadOnly(True)
        self.infoText.setWordWrapMode(QtGui.QTextOption.WordWrap)

        #show the window
        self.mainWin.show()

        self.getHistory()
Example #12
0
    def populateTable(self):

        pixmap = QtGui.QPixmap(20, 20)
        pixmap.fill(QtGui.QColor(0, 255, 0))
        iconOn = QtGui.QIcon(pixmap)

        pixmapOff = QtGui.QPixmap(20, 20)
        pixmapOff.fill(QtGui.QColor(255, 0, 0))
        iconOff = QtGui.QIcon(pixmapOff)

        modules = utils.returnRigModules()
        self.modTable.setRowCount(100 + len(modules))
        counter = 0
        for module in modules:

            aimState = False
            pinState = False

            #get module name
            moduleName = cmds.getAttr(module + ".moduleName")

            if cmds.objExists(module + ".aimMode"):
                aimState = cmds.getAttr(module + ".aimMode")
            if cmds.objExists(module + ".pinned"):
                pinState = cmds.getAttr(module + ".pinned")

            moduleItem = QtWidgets.QTableWidgetItem(moduleName)
            self.modTable.setItem(counter, 0, moduleItem)

            if aimState:
                lockItem = QtWidgets.QTableWidgetItem(iconOn, "")
            else:
                lockItem = QtWidgets.QTableWidgetItem(iconOff, "")

            self.modTable.setItem(counter, 2, lockItem)

            if pinState:
                pinItem = QtWidgets.QTableWidgetItem(iconOn, "")
            else:
                pinItem = QtWidgets.QTableWidgetItem(iconOff, "")

            self.modTable.setItem(counter, 1, pinItem)

            counter += 1
Example #13
0
    def findCharacterModules(self, *args):

        self.fbxModuleList.clear()

        #current character
        selectedChar = self.fbxCharacterCombo.currentText()

        #get rig modules
        if cmds.objExists(selectedChar + ":" + "ART_RIG_ROOT"):
            modules = cmds.listConnections(selectedChar + ":" +
                                           "ART_RIG_ROOT.rigModules")

            for module in modules:
                niceName = cmds.getAttr(module + ".moduleName")
                moduleType = cmds.getAttr(module + ".moduleType")

                #create widget
                item = QtWidgets.QListWidgetItem()

                widgetItem = QtWidgets.QGroupBox()
                widgetItem.setMinimumHeight(40)
                widgetItem.setProperty("module", module)
                widgetItem.setObjectName("light")

                layout = QtWidgets.QHBoxLayout(widgetItem)
                label = QtWidgets.QLabel(niceName)
                label.setStyleSheet("background: transparent; font: bold;")
                layout.addWidget(label)

                comboBox = QtWidgets.QComboBox()
                layout.addWidget(comboBox)

                #add items to combo box bases on module class var
                mod = __import__("RigModules." + moduleType, {}, {},
                                 [moduleType])
                fbxOptions = mod.fbxImport

                for each in fbxOptions:
                    comboBox.addItem(each)

                comboBox.setCurrentIndex(1)

                self.fbxModuleList.addItem(item)
                self.fbxModuleList.setItemWidget(item, widgetItem)
Example #14
0
    def createContextMenu(self, point):

        self.contextMenu = QtWidgets.QMenu()

        selectIcon = QtGui.QIcon((utils.returnFriendlyPath(
            os.path.join(self.iconsPath, "System/select.png"))))

        self.contextMenu.addAction(selectIcon, "Select All",
                                   self.selectAllInList)
        self.contextMenu.addAction("Clear Selection", self.clearListSelection)

        self.contextMenu.exec_(self.moduleList.mapToGlobal(point))
    def buildUI(self):

        if cmds.window("pyART_AddToCanvasWIN", exists=True):
            cmds.deleteUI("pyART_AddToCanvasWIN", wnd=True)

        #create the main window
        self.mainWin = QtWidgets.QMainWindow(self.pickerUI)

        #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(250, 400))
        self.mainWin.setMaximumSize(QtCore.QSize(250, 400))
        self.mainWin.resize(250, 400)

        #set qt object name
        self.mainWin.setObjectName("pyART_AddToCanvasWIN")
        self.mainWin.setWindowTitle("Remove Module From Canvas")

        #label, listWidget, button
        label = QtWidgets.QLabel("Available Modules:")
        label.setProperty("boldFont", True)
        self.layout.addWidget(label)

        self.moduleList = QtWidgets.QListWidget()
        self.moduleList.setMaximumSize(230, 300)
        self.moduleList.setMinimumSize(230, 300)
        self.layout.addWidget(self.moduleList)

        #add modules to listWidget
        self.addModulesToList()

        #create remove button
        button = QtWidgets.QPushButton("Remove From Canvas")
        self.layout.addWidget(button)
        button.setObjectName("blueButton")
        button.clicked.connect(self.removeFromCanvas)

        #show ui
        self.mainWin.show()
Example #16
0
    def findCharacterModules(self, *args):

        self.moduleList.clear()

        #current character
        selectedChar = self.characterCombo.currentText()

        #get rig modules
        if cmds.objExists(selectedChar + ":" + "ART_RIG_ROOT"):
            modules = cmds.listConnections(selectedChar + ":" +
                                           "ART_RIG_ROOT.rigModules")

            for module in modules:
                modName = cmds.getAttr(module + ".moduleName")
                item = QtWidgets.QListWidgetItem(modName)
                item.setData(QtCore.Qt.UserRole, module)
                self.moduleList.addItem(item)
Example #17
0
    def unsavedChanges(self, path):
        """
        Displays a message box that warns the user of unsaved file changed and returns their response.

        :return: Returns the user response (Save, Don't Save, Cancel)

        """

        # message box for letting user know current file has unsaved changes
        msgBox = QtWidgets.QMessageBox()
        msgBox.setIcon(QtWidgets.QMessageBox.Warning)
        msgBox.setText("Current File Has Unsaved Changes!")
        msgBox.addButton("Save Changes", QtWidgets.QMessageBox.YesRole)
        msgBox.addButton("Don't Save", QtWidgets.QMessageBox.NoRole)
        msgBox.addButton("Cancel", QtWidgets.QMessageBox.NoRole)
        ret = msgBox.exec_()

        return ret
Example #18
0
    def __init__(self, width, height, relativePos, controlObj, brush, parent=None):

        super(pickerButton, self).__init__(parent)

        self.parentItem().setZValue(1)
        self.setZValue(2)

        self.brush = QtGui.QBrush(brush)
        self.brushColor = brush

        self.width = width
        self.height = height
        self.relativePos = relativePos
        self.object = controlObj

        self.setPos(self.parentItem().boundingRect().topLeft())
        self.setPos(self.pos().x() + self.relativePos[0], self.pos().y() + self.relativePos[1])
        self.menu = QtWidgets.QMenu()

        self.classType = "pickerButton"
Example #19
0
    def addJointMoverToOutliner(self):

        index = self.rigUiInst.treeWidget.topLevelItemCount()

        #Add the module to the tree widget in the outliner tab of the rig creator UI
        self.outlinerWidgets[self.name +
                             "_treeModule"] = QtWidgets.QTreeWidgetItem(
                                 self.rigUiInst.treeWidget)
        self.rigUiInst.treeWidget.topLevelItem(index).setText(0, self.name)
        foreground = QtGui.QBrush(QtGui.QColor(255, 255, 255))
        self.outlinerWidgets[self.name + "_treeModule"].setForeground(
            0, foreground)
        #add the buttons
        self.createGlobalMoverButton(
            self.name, self.outlinerWidgets[self.name + "_treeModule"],
            self.rigUiInst)

        #create selection script job for module
        self.updateBoneCount()
        self.createScriptJob()
Example #20
0
def addTextToButton(text, parent, centered=True, top=False, bottom=False):
    text = QtWidgets.QGraphicsSimpleTextItem(text, parent)
    font = QtGui.QFont()
    font.setBold(True)
    font.setPointSize(12)

    text.setFont(font)
    textPos = parent.boundingRect().center()
    textRect = text.boundingRect()
    parentRect = parent.boundingRect()

    if centered:
        text.setPos(textPos.x() - textRect.width() / 2, textPos.y() - textRect.height() / 2)

    if top:
        text.setPos(textPos.x() - textRect.width() / 2, textPos.y() - (parentRect.height() / 2 + textRect.height()))

    if bottom:
        text.setPos(textPos.x() - textRect.width() / 2, textPos.y() + (parentRect.height() / 2))

    return text
Example #21
0
    def saveSettings(self):

        #loop through each of the modules and read the qComboBox value
        moduleItems = []
        for i in range(self.fbxModuleList.count()):
            item = self.fbxModuleList.item(i)
            itemWidget = self.fbxModuleList.itemWidget(item)
            itemModule = itemWidget.property("module")

            children = itemWidget.children()
            for child in children:
                if type(child) == QtWidgets.QComboBox:
                    importMethod = child.currentIndex()
                    moduleItems.append([itemModule, importMethod])

        #save import settings in the settings folder
        if not os.path.exists(os.path.join(self.toolsPath, "settings")):
            os.makedirs(os.path.join(self.toolsPath, "settings"))

        if not os.path.exists(
                os.path.join(self.toolsPath,
                             "settings" + os.sep + "importSettings")):
            os.makedirs(
                os.path.join(self.toolsPath,
                             "settings" + os.sep + "importSettings"))

        #open a file browser dialog for user to name file
        dialog = QtWidgets.QFileDialog(
            None, "Save",
            os.path.join(self.toolsPath,
                         "settings" + os.sep + "importSettings"))
        dialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
        dialog.setDefaultSuffix("json")
        dialog.exec_()
        fileName = dialog.selectedFiles()

        #write file
        f = open(fileName[0], 'w')
        json.dump(moduleItems, f)
        f.close()
Example #22
0
    def __init__(self, width, height, pointArray, relativePos, controlObj, brush, parent=None):

        super(pickerButtonCustom, self).__init__(parent)

        self.parentItem().setZValue(1)
        self.setZValue(2)

        self.brush = QtGui.QBrush(brush)
        self.brushColor = brush
        self.pointArray = pointArray
        self.poly = self.createPolygon()
        self.setPolygon(self.poly)

        # position item
        self.relativePos = relativePos
        self.object = controlObj
        self.setPos(self.parentItem().boundingRect().topLeft())
        self.setPos(self.pos().x() + self.relativePos[0], self.pos().y() + self.relativePos[1])

        # create menu
        self.menu = QtWidgets.QMenu()
        self.classType = "pickerButton"
Example #23
0
    def __init__(self, parent=None):

        super(ART_ModStatusWin, 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")

        #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)

        #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.QHBoxLayout(self.mainWidget)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.setMinimumSize(QtCore.QSize(300, 400))
        self.setMaximumSize(QtCore.QSize(300, 600))
        self.resize(QtCore.QSize(300, 400))

        #create the background
        self.frame = QtWidgets.QFrame()
        self.frame.setObjectName("mid")
        self.mainLayout.addWidget(self.frame)

        #create the widget layout
        self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)

        #create the table widget
        self.modTable = QtWidgets.QTableWidget()
        self.modTable.setObjectName("mid")
        self.widgetLayout.addWidget(self.modTable)
        self.modTable.setColumnCount(3)
        self.modTable.setHorizontalHeaderLabels(["Module", "Pinned", "Aiming"])
        self.modTable.setColumnWidth(0, 100)
        self.modTable.setColumnWidth(1, 65)
        self.modTable.setColumnWidth(2, 65)

        #populate the table widget
        self.populateTable()

        #add refresh button
        self.refreshButton = QtWidgets.QPushButton("Refresh")
        self.widgetLayout.addWidget(self.refreshButton)
        self.refreshButton.setObjectName("blueButton")
        self.refreshButton.clicked.connect(self.refresh)

        self.show()
Example #24
0
    def __init__(self, currentParent, moduleInst, rigUiInst, parent=None):
        """
        Instantiates the class, taking in current module information, and builds the interface.

        :param currentParent: The current module parent bone of this module.
        :param moduleInst: The instance in memory of the module whose name is to change.
        :param rigUiInst: The instance in memory of the Rig Creator UI from which this class was called.

        """
        super(ART_ChangeModuleParent_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.currentParent = currentParent
        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, 400))
        self.setMaximumSize(QtCore.QSize(250, 400))

        # create the background image
        self.frame = QtWidgets.QFrame()
        self.mainLayout.addWidget(self.frame)
        self.frame.setObjectName("mid")

        # create the layout for the widgets
        self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)

        label = QtWidgets.QLabel("Choose New Parent:")
        font = QtGui.QFont()
        font.setBold(True)
        label.setFont(font)
        self.widgetLayout.addWidget(label)

        self.boneSearch = QtWidgets.QLineEdit()
        self.boneSearch.setPlaceholderText("Search..")
        self.boneSearch.textChanged.connect(self.searchList)
        self.widgetLayout.addWidget(self.boneSearch)
        self.boneList = QtWidgets.QListWidget()
        self.widgetLayout.addWidget(self.boneList)
        self.boneList.setMinimumHeight(200)

        # add items to comboBox
        bones = utils.getViableParents()

        # get our own bones
        modBones = self.modInst.returnCreatedJoints

        for bone in bones:
            if bone not in modBones:
                self.boneList.addItem(bone)
            if bone == "root":
                index = bones.index(bone)
                self.boneList.setCurrentRow(index)

        # 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.applyModuleParentChange)

        self.updateBtn.setFocus()
Example #25
0
    def finalizeSetup_UI(self):

        if cmds.window("ART_finalizeSetupWin", exists=True):
            cmds.deleteUI("ART_finalizeSetupWin", wnd=True)

        #launch a UI to get the name information
        self.finalizeSetupWin = QtWidgets.QMainWindow(self.mainUI)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        #load toolbar stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.finalizeSetupWin.setStyleSheet(self.style)

        #create the main widget
        self.finalizeSetupWin_mainWidget = QtWidgets.QWidget()
        self.finalizeSetupWin.setCentralWidget(
            self.finalizeSetupWin_mainWidget)

        #set qt object name
        self.finalizeSetupWin.setObjectName("ART_finalizeSetupWin")
        self.finalizeSetupWin.setWindowTitle("Finalize Setup")

        #create the mainLayout for the rig creator UI
        self.finalizeSetupWin_mainLayout = QtWidgets.QVBoxLayout(
            self.finalizeSetupWin_mainWidget)
        self.finalizeSetupWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.finalizeSetupWin.resize(450, 300)
        self.finalizeSetupWin.setSizePolicy(mainSizePolicy)
        self.finalizeSetupWin.setMinimumSize(QtCore.QSize(450, 300))
        self.finalizeSetupWin.setMaximumSize(QtCore.QSize(450, 300))

        #create the background image
        self.finalizeSetupWin_frame = QtWidgets.QFrame()
        self.finalizeSetupWin_mainLayout.addWidget(self.finalizeSetupWin_frame)

        #create the main vertical layout inside the frame
        self.finalizeSetupWin_mainVLayout = QtWidgets.QVBoxLayout(
            self.finalizeSetupWin_frame)

        # # # # TEXT EDIT # # # #
        self.finalizeSetupWin_Text = QtWidgets.QTextEdit()
        self.finalizeSetupWin_Text.setMinimumSize(QtCore.QSize(440, 230))
        self.finalizeSetupWin_Text.setMaximumSize(QtCore.QSize(440, 230))
        self.finalizeSetupWin_mainVLayout.addWidget(self.finalizeSetupWin_Text)
        self.finalizeSetupWin_Text.setReadOnly(True)
        self.finalizeSetupWin_Text.setAcceptRichText(True)

        #text
        text = "Finalizing the setup will create the skeleton that will be used for skin binding."
        cursor = self.finalizeSetupWin_Text.textCursor()
        cursor.insertText(text)

        text = "\nIt is recommended that offsets are baked before continuing.  "
        self.finalizeSetupWin_Text.setTextColor(QtGui.QColor(236, 217, 0))
        self.finalizeSetupWin_Text.setFontPointSize(10)
        self.finalizeSetupWin_Text.append(text)

        #image
        image2 = utils.returnNicePath(self.iconsPath, "System/bakeOffsets.png")
        icon = QtGui.QPixmap(image2)
        image = icon.toImage()
        cursor.insertImage(image)

        text = "\n(You will still be able to edit your setup by coming back to this step using the 'Edit Setup' button seen in the deformation tools interface):\n\n"
        self.finalizeSetupWin_Text.setTextColor(QtGui.QColor(255, 255, 255))
        self.finalizeSetupWin_Text.setFontPointSize(8)
        self.finalizeSetupWin_Text.append(text)

        #image
        image2 = utils.returnNicePath(self.iconsPath,
                                      "System/finalizeSetup.png")
        icon = QtGui.QPixmap(image2)
        image = icon.toImage()
        cursor.insertImage(image)

        self.finalizeSetupWin_Text.setTextCursor(cursor)
        end = "<br>"
        fragment = QtGui.QTextDocumentFragment.fromHtml(end)
        cursor.insertFragment(fragment)
        # # # # END TEXT EDIT # # # #

        # # # # BUTTON LAYOUT # # # #
        self.finalizeSetupWin_buttonLayout = QtWidgets.QHBoxLayout()
        self.finalizeSetupWin_mainVLayout.addLayout(
            self.finalizeSetupWin_buttonLayout)

        self.finalizeSetupWin_ContinueBtn = QtWidgets.QPushButton("Continue")
        self.finalizeSetupWin_CancelBtn = QtWidgets.QPushButton("Cancel")
        self.finalizeSetupWin_HelpBtn = QtWidgets.QPushButton("?")
        self.finalizeSetupWin_HelpBtn.setMinimumSize(QtCore.QSize(25, 25))
        self.finalizeSetupWin_HelpBtn.setMaximumSize(QtCore.QSize(25, 25))
        self.finalizeSetupWin_buttonLayout.addWidget(
            self.finalizeSetupWin_ContinueBtn)
        self.finalizeSetupWin_buttonLayout.addWidget(
            self.finalizeSetupWin_CancelBtn)
        self.finalizeSetupWin_buttonLayout.addWidget(
            self.finalizeSetupWin_HelpBtn)

        self.finalizeSetupWin_ContinueBtn.clicked.connect(
            partial(self.finalizeSetup_Continue))
        self.finalizeSetupWin_CancelBtn.clicked.connect(
            partial(self.finalizeSetup_Cancel))
        self.finalizeSetupWin_HelpBtn.clicked.connect(
            partial(self.finalizeSetup_Help))

        self.finalizeSetupWin_ContinueBtn.setObjectName("blueButton")
        self.finalizeSetupWin_CancelBtn.setObjectName("blueButton")
        self.finalizeSetupWin_HelpBtn.setObjectName("blueButton")
        # # # # END BUTTON LAYOUT # # # #

        #show window
        self.finalizeSetupWin_Text.moveCursor(QtGui.QTextCursor.Start)
        self.finalizeSetupWin.show()
Example #26
0
    def createUI(self):
        """
        Builds the UI, listing options for choosing a project and showing all assets belonging to that project for
        edit or add.

        """

        # fonts
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)

        fontSmall = QtGui.QFont()
        fontSmall.setPointSize(9)
        fontSmall.setBold(True)

        # load stylesheet
        styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.setStyleSheet(self.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)
        if self.edit:
            self.setWindowTitle(windowTitle)
        if self.add:
            self.setWindowTitle("Add Rig For Animation")

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        # create the mainLayout
        self.layout = QtWidgets.QVBoxLayout(self.mainWidget)

        self.resize(400, 400)
        self.setSizePolicy(mainSizePolicy)
        self.setMinimumSize(QtCore.QSize(400, 400))
        self.setMaximumSize(QtCore.QSize(400, 400))

        # create the QFrame
        self.frame = QtWidgets.QFrame()
        self.layout.addWidget(self.frame)
        self.widgetLayout = QtWidgets.QHBoxLayout(self.frame)
        self.frame.setObjectName("mid")

        # =======================================================================
        # #create two VBox Layouts to create 2 columns
        # =======================================================================
        self.leftColumn = QtWidgets.QVBoxLayout()
        self.widgetLayout.addLayout(self.leftColumn)

        self.rightColumn = QtWidgets.QVBoxLayout()
        self.widgetLayout.addLayout(self.rightColumn)

        # =======================================================================
        # #left column : project comboBox, group comboBox, listWidget of characters
        # =======================================================================

        self.projectMenu = QtWidgets.QComboBox()
        self.leftColumn.addWidget(self.projectMenu)
        self.projectMenu.setMinimumSize(150, 30)
        self.projectMenu.setMaximumSize(150, 30)
        self.projectMenu.currentIndexChanged.connect(self.populateGroups)

        self.groupMenu = QtWidgets.QComboBox()
        self.leftColumn.addWidget(self.groupMenu)
        self.groupMenu.setMinimumSize(150, 30)
        self.groupMenu.setMaximumSize(150, 30)
        self.groupMenu.currentIndexChanged.connect(self.populateCharacters)

        self.characterList = QtWidgets.QListWidget()
        self.leftColumn.addWidget(self.characterList)
        self.characterList.setMinimumSize(150, 200)
        self.characterList.setMaximumSize(150, 200)
        self.characterList.itemClicked.connect(partial(self.populateIcon))
        self.populateProjects()
        # =======================================================================
        # #right column: icon frame, edit button/add button, close button
        # =======================================================================

        self.characterIcon = QtWidgets.QLabel()
        self.characterIcon.setMinimumSize(200, 200)
        self.characterIcon.setMaximumSize(200, 200)
        self.rightColumn.addWidget(self.characterIcon)

        # default image
        self.defaultPixMap = QtGui.QPixmap(utils.returnNicePath(self.iconsPath, "System/noCharacter.png"))
        self.characterIcon.setPixmap(self.defaultPixMap)

        # if edit:
        if self.edit:
            self.editButton = QtWidgets.QPushButton("Edit Selected")
            self.editButton.setFont(font)
            self.rightColumn.addWidget(self.editButton)
            self.editButton.setMinimumSize(200, 40)
            self.editButton.setMaximumSize(200, 40)
            self.editButton.clicked.connect(partial(self.editSelected))
            self.editButton.setObjectName("blueButton")

        # if add:
        if self.add:
            self.addButton = QtWidgets.QPushButton("Add Selected")
            self.addButton.setFont(font)
            self.rightColumn.addWidget(self.addButton)
            self.addButton.setMinimumSize(200, 40)
            self.addButton.setMaximumSize(200, 40)
            self.addButton.clicked.connect(partial(self.addSelected))
            self.addButton.setObjectName("blueButton")

        self.closeButton = QtWidgets.QPushButton("Close")
        self.closeButton.setFont(font)
        self.rightColumn.addWidget(self.closeButton)
        self.closeButton.setMinimumSize(200, 40)
        self.closeButton.setMaximumSize(200, 40)
        self.closeButton.clicked.connect(partial(self.closeUI))
        self.closeButton.setObjectName("blueButton")
Example #27
0
    def buildImportWeightsUI(self):
        """
        Build the interface for importing skin weights. The interface will create an entry for every piece of selected
        geometry.

        The interface will look like this:

        .. image:: /images/importWeights.png

        """
        if cmds.window("ART_importSkinWeightsUI", exists=True):
            cmds.deleteUI("ART_importSkinWeightsUI", wnd=True)

        # launch a UI to get the name information
        self.importSkinWeights_Win = QtWidgets.QMainWindow(self.mainUI)

        # load stylesheet
        styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.importSkinWeights_Win.setStyleSheet(self.style)

        # create the main widget
        self.importSkinWeights_mainWidget = QtWidgets.QWidget()
        self.importSkinWeights_Win.setCentralWidget(self.importSkinWeights_mainWidget)

        # set qt object name
        self.importSkinWeights_Win.setObjectName("ART_importSkinWeightsUI")
        self.importSkinWeights_Win.setWindowTitle("Import Skin Weights")

        # create the mainLayout for the ui
        self.importSkinWeights_mainLayout = QtWidgets.QVBoxLayout(self.importSkinWeights_mainWidget)
        self.importSkinWeights_mainLayout.setContentsMargins(5, 5, 5, 5)

        self.importSkinWeights_Win.resize(450, 400)
        # self.importSkinWeights_Win.setSizePolicy(mainSizePolicy)
        self.importSkinWeights_Win.setMinimumSize(QtCore.QSize(450, 400))
        self.importSkinWeights_Win.setMaximumSize(QtCore.QSize(450, 400))

        # create the background image
        self.importSkinWeights_frame = QtWidgets.QFrame()
        self.importSkinWeights_mainLayout.addWidget(self.importSkinWeights_frame)
        self.importSkinWeights_frame.setObjectName("dark")

        # create widgetLayout
        self.importSkinWeights_widgetLayout = QtWidgets.QVBoxLayout(self.importSkinWeights_frame)

        # import skin weights method
        # self.importSkinWeights_methodForm = QtWidgets.QHBoxLayout()
        # self.importSkinWeights_widgetLayout.addLayout(self.importSkinWeights_methodForm)
        #
        # label = QtWidgets.QLabel("Import Method:  ")
        # label.setStyleSheet("background: transparent;")
        # self.importSkinWeights_methodForm.addWidget(label)

        # self.importSkinWeights_importMethod = QtWidgets.QComboBox()
        # self.importSkinWeights_methodForm.addWidget(self.importSkinWeights_importMethod)
        # self.importSkinWeights_importMethod.addItem("Vertex Order")
        # self.importSkinWeights_importMethod.addItem("World Position")
        # self.importSkinWeights_importMethod.addItem("Local Position")
        # self.importSkinWeights_importMethod.addItem("UV Position")

        # scroll area contents
        self.importSkinWeights_scrollContents = QtWidgets.QFrame()
        self.importSkinWeights_scrollContents.setObjectName("light")

        # Layout of Container Widget
        self.importSkinWeights_VLayout = QtWidgets.QVBoxLayout()
        self.importSkinWeights_VLayout.setSpacing(5)

        # find selected geometry and populate scroll area
        self.importSkinWeights_populate()

        # add scrollArea for selected geo, skinFileName, and checkbox for importing
        self.importSkinWeights_scrollLayout = QtWidgets.QScrollArea()
        self.importSkinWeights_widgetLayout.addWidget(self.importSkinWeights_scrollLayout)
        self.importSkinWeights_scrollLayout.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.importSkinWeights_scrollLayout.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.importSkinWeights_scrollLayout.setWidgetResizable(False)
        self.importSkinWeights_scrollLayout.setWidget(self.importSkinWeights_scrollContents)

        # refresh and import button
        font = QtGui.QFont()
        font.setPointSize(8)
        font.setBold(True)

        self.importSkinWeights_BtnLayout = QtWidgets.QHBoxLayout()
        self.importSkinWeights_widgetLayout.addLayout(self.importSkinWeights_BtnLayout)

        self.importSkinWeights_RefreshBtn = QtWidgets.QPushButton("Refresh")
        self.importSkinWeights_BtnLayout.addWidget(self.importSkinWeights_RefreshBtn)
        self.importSkinWeights_RefreshBtn.setMinimumSize(QtCore.QSize(70, 50))
        self.importSkinWeights_RefreshBtn.setMaximumSize(QtCore.QSize(70, 50))
        self.importSkinWeights_RefreshBtn.setFont(font)
        self.importSkinWeights_RefreshBtn.clicked.connect(partial(self.buildImportWeightsUI))
        self.importSkinWeights_RefreshBtn.setObjectName("blueButton")

        self.importSkinWeights_ImportBtn = QtWidgets.QPushButton("IMPORT WEIGHTS")
        self.importSkinWeights_BtnLayout.addWidget(self.importSkinWeights_ImportBtn)
        self.importSkinWeights_ImportBtn.setMinimumSize(QtCore.QSize(350, 50))
        self.importSkinWeights_ImportBtn.setMaximumSize(QtCore.QSize(350, 50))
        self.importSkinWeights_ImportBtn.setFont(font)
        self.importSkinWeights_ImportBtn.clicked.connect(partial(self.importSkinWeights_DoImport))
        self.importSkinWeights_ImportBtn.setObjectName("blueButton")

        # lastly, progress bar
        self.importSkinWeights_progBarTotal = QtWidgets.QProgressBar()
        self.importSkinWeights_widgetLayout.addWidget(self.importSkinWeights_progBarTotal)
        self.importSkinWeights_progBarTotal.setRange(0, self.importSkinWeights_VLayout.count() - 1)
        self.importSkinWeights_progBarTotal.setValue(0)

        self.importSkinWeights_progBarCurrent = QtWidgets.QProgressBar()
        self.importSkinWeights_widgetLayout.addWidget(self.importSkinWeights_progBarCurrent)
        self.importSkinWeights_progBarCurrent.setRange(0, 100)
        self.importSkinWeights_progBarCurrent.setValue(0)

        # show window
        self.importSkinWeights_Win.show()
Example #28
0
    def importSkinWeights_DoImport(self):
        """
        Gather the information from the interface and import the skin weights with that information.

        For each piece of geometry, get the associated .weight file on disk, then call on import_skin_weights
        from riggingUtils, passing in the .weight file path and the mesh.

        """
        # which method?
        # method = self.importSkinWeights_importMethod.currentText()

        # error report messages
        errorMessages = []

        # weight files
        weightFiles = []

        # find each lineEdit in the scrollArea and get the entered text
        for i in range(self.importSkinWeights_VLayout.count()):
            hboxLayout = self.importSkinWeights_VLayout.itemAt(i)
            value, fileName, mesh = None, None, None
            for x in range(hboxLayout.count()):
                widget = hboxLayout.itemAt(x)
                # go through each widget in the hboxLayout, and get values
                if type(widget.widget()) == QtWidgets.QLabel:
                    geoName = widget.widget().text()
                    geoName = geoName.partition(" :")[0]
                    if cmds.objExists(geoName):
                        mesh = cmds.ls(geoName, long=True)[0]

                # see if the user wants to export the weights for this entry
                if type(widget.widget()) == QtWidgets.QCheckBox:
                    value = widget.widget().isChecked()

                # get the fileName
                if type(widget.widget()) == QtWidgets.QLineEdit:
                    fileName = widget.widget().text()

                    # if the box is checked for import, do the import
            if (value and mesh and fileName):
                ###############################
                # BEGIN WEIGHT IMPORT

                # try to load the given file
                if os.path.exists(fileName):
                    weightFiles.append(fileName)
                else:
                    cmds.error('ART_ImportWeights: Skin file does not exist: ' + fileName)
                    return False
                if not mesh:
                    cmds.error('ART_ImportWeights: Mesh does not exist!')
                    return False
                # update the total progress bar
                incrementValue = self.importSkinWeights_progBarTotal.value() + 1
                self.importSkinWeights_progBarTotal.setValue(incrementValue)

                # create a skinWeights class with the skin file
                if fileName:
                    print 'Loading skinWeights from ', str(fileName)
                    riggingUtils.import_skin_weights(fileName, mesh, True)

        # ask if user wants to delete weight files
        file_string = ""
        for file in weightFiles:
            file_name = os.path.basename(file)
            file_string += file_name + "\n"

        msgBox = QtWidgets.QMessageBox()
        msgBox.setIcon(QtWidgets.QMessageBox.Warning)
        msgBox.setText("Would you like to delete the following weight files?")
        msgBox.setDetailedText(file_string)
        msgBox.addButton("Yes", QtWidgets.QMessageBox.YesRole)
        msgBox.addButton("No", QtWidgets.QMessageBox.NoRole)
        ret = msgBox.exec_()

        if ret == 0:
            for file in weightFiles:
                try:
                    os.remove(file)
                except:
                    cmds.warning("Unable to delete file: " + str(file))
        if ret == 1:
            return
Example #29
0
    def importSkinWeights_populate(self):
        """
        Populate the interface with an entry for each piece of selected geometry. Each entry will have the geometry
        name and allow the user to point to the geometry's .weight file.
        """

        # get current selection
        selection = cmds.ls(sl=True)
        if len(selection) > 0:

            # Create headers
            font = QtGui.QFont()
            font.setPointSize(12)
            font.setBold(True)

            headerLayout = QtWidgets.QHBoxLayout()
            self.importSkinWeights_VLayout.addLayout(headerLayout)
            headerExport = QtWidgets.QLabel(" ")
            headerExport.setStyleSheet("background: transparent;")
            headerLayout.addWidget(headerExport)

            headerGeo = QtWidgets.QLabel("Mesh")
            headerGeo.setStyleSheet("background: transparent;")
            headerGeo.setMinimumSize(QtCore.QSize(180, 20))
            headerGeo.setMaximumSize(QtCore.QSize(180, 20))
            headerLayout.addWidget(headerGeo)
            headerGeo.setFont(font)

            headerFileName = QtWidgets.QLabel("Weight File")
            headerFileName.setStyleSheet("background: transparent;")
            headerLayout.addWidget(headerFileName)
            headerFileName.setMinimumSize(QtCore.QSize(180, 20))
            headerFileName.setMaximumSize(QtCore.QSize(180, 20))
            headerFileName.setFont(font)

            # get a list of weight files
            weightFiles = []
            for root, subFolders, files in os.walk(self.toolsPath):
                for file in files:
                    if file.rpartition(".")[2] == "weights":
                        fullPath = utils.returnFriendlyPath(os.path.join(root, file))

                        weightFiles.append(fullPath)
            print weightFiles
            # loop through selection, checking selection is valid and has skinCluster
            for each in selection:

                try:
                    # get dagPath and shape and create a nice display name
                    dagPath = cmds.ls(each, long=True)[0]
                    shapeNode = cmds.listRelatives(dagPath, children=True)
                    nicename = each.rpartition("|")[2]
                except Exception, e:
                    traceback.format_exc()

                try:
                    if cmds.nodeType(dagPath + "|" + shapeNode[0]) == "mesh":
                        # create HBoxLayout
                        layout = QtWidgets.QHBoxLayout()
                        layout.setSpacing(10)
                        self.importSkinWeights_VLayout.addLayout(layout)

                        # create checkbox
                        checkBox = QtWidgets.QCheckBox()
                        layout.addWidget(checkBox)
                        checkBox.setChecked(True)

                        # create non editable line edit
                        geoName = QtWidgets.QLabel(nicename + " : ")
                        geoName.setStyleSheet("background: transparent;")
                        geoName.setProperty("dag", dagPath)
                        layout.addWidget(geoName)
                        geoName.setMinimumSize(QtCore.QSize(100, 30))
                        geoName.setMaximumSize(QtCore.QSize(100, 30))

                        # create editable line edit
                        skinFileName = QtWidgets.QLineEdit()
                        layout.addWidget(skinFileName)
                        skinFileName.setMinimumSize(QtCore.QSize(205, 30))
                        skinFileName.setMaximumSize(QtCore.QSize(205, 30))

                        # try to find a matching weight file
                        for file in weightFiles:
                            compareString = file.rpartition("/")[2].partition(".")[0]
                            if nicename.lower() == compareString.lower():
                                skinFileName.setText(file)

                        # check if geometry has weights file associated already
                        if cmds.objExists(dagPath + ".weightFile"):
                            path = cmds.getAttr(dagPath + ".weightFile")
                            path = utils.returnFriendlyPath(path)
                            if os.path.exists(path):
                                skinFileName.setText(path)

                        # browse button
                        browseBtn = QtWidgets.QPushButton()
                        layout.addWidget(browseBtn)
                        browseBtn.setMinimumSize(35, 35)
                        browseBtn.setMaximumSize(35, 35)
                        icon = QtGui.QIcon(os.path.join(self.iconsPath, "System/fileBrowse.png"))
                        browseBtn.setIconSize(QtCore.QSize(30, 30))
                        browseBtn.setIcon(icon)
                        browseBtn.clicked.connect(partial(self.importSkinWeights_fileBrowse, skinFileName))
                except Exception, e:
                    print traceback.format_exc()
Example #30
0
                        browseBtn = QtWidgets.QPushButton()
                        layout.addWidget(browseBtn)
                        browseBtn.setMinimumSize(35, 35)
                        browseBtn.setMaximumSize(35, 35)
                        icon = QtGui.QIcon(os.path.join(self.iconsPath, "System/fileBrowse.png"))
                        browseBtn.setIconSize(QtCore.QSize(30, 30))
                        browseBtn.setIcon(icon)
                        browseBtn.clicked.connect(partial(self.importSkinWeights_fileBrowse, skinFileName))
                except Exception, e:
                    print traceback.format_exc()

            # add spacer
            self.importSkinWeights_scrollContents.setLayout(self.importSkinWeights_VLayout)

        else:
            label = QtWidgets.QLabel("No Geometry Selected For Import. Select Geometry and Relaunch.")
            label.setAlignment(QtCore.Qt.AlignCenter)
            self.importSkinWeights_VLayout.addWidget(label)


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    def importSkinWeights_fileBrowse(self, lineEdit):
        """
        Open a file dialog that the user can use to browse to the .weight file, then set the text of the passed-in
        line edit to be the path to the .weights file.

        :param lineEdit: QLineEdit to set path text to.
        """

        # Need support for defaulting to current project character was last published to and creating character