Example #1
0
    def populateRigList(self):

        with PreserveSelection():

            rigs = Rig.list()
            self._count = len(rigs)

            for child in self._listLayout.children():
                pm.deleteUI(child)

            for rig in rigs:
                with self._listLayout:
                    rigUi = RigListItem(rig, self.populateRigList)

            self.refresh()
Example #2
0
    def createRig(self):

        selection = set(pm.selected())

        rigs = [rig.node for rig in Rig.list()]
        pm.select(rigs, hierarchy=True)
        rigObjects = set(pm.selected())

        trimmedSelection = selection - rigObjects
        pm.select(trimmedSelection)

        jointFound = len(pm.ls(selection = True, type = pm.nt.Joint)) > 0
        shapeFound = False
        for transform in pm.ls(selection = True, type = pm.nt.Transform):
            if transform.getShape():
                shapeFound = True
                break

        if not jointFound or not shapeFound:

            message = 'Create rig without {0}{1}{2}?'.format(
                'joints' if not jointFound else '',
                ' or '   if not jointFound and not shapeFound else '',
                'shapes' if not shapeFound else ''
            )

            dialog = ConfirmationDialog(
                title   = 'Rig Manager | Create',
                message = message,
                confirm = 'Create',
                deny    = 'Cancel',
                icon    = Window.Icon.QUESTION
            )

            if not dialog.confirm():
                return

        pm.select(clear = True)
        newRig = Rig(name = self._nameInput.getText())
        newRig.rigging[Attribute.VISIBILITY] = False
        pm.parent(trimmedSelection, newRig.final)

        with self._listLayout:
            rigUi = RigListItem(newRig, self.populateRigList)

        pm.select(newRig.node)