Ejemplo n.º 1
0
    def on_btn_replace_clicked(self, clicked=None):
        if clicked == None:
            return

        polyGeometry = mc.ls(type="mesh")
        if not polyGeometry:
            print "# Error # No polyGon geometrys...",
            return
        polyGeometry = mc.listRelatives(polyGeometry, p=True)
        polyGeometry = dict.fromkeys(polyGeometry).keys()

        selectIndexes = self.listView.selectedIndexes()
        if not selectIndexes:
            print "# Error # - You must select a model file...",
            return
        index = selectIndexes[0].row()
        modelPath = self.asset_data[index]

        if not uiTool.warning(message="Model's UV will be replaced, and it can not to undo !!!\nContinue ? ?"):
            return

        # - refrence
        f = mc.file(modelPath, r=True, namespace="UV")

        self.progressBar.setMaximum(len(polyGeometry))
        for i, geo in enumerate(polyGeometry):
            self.progressBar.setValue(i)
            self.btn_replace.setText("%d%%" % mathTool.setRange(0, len(polyGeometry), 0, 100, i))

            realName = re.search("\w+$", geo).group()
            UVgeo = "UV:%s" % realName
            if not mc.objExists(UVgeo):
                print "# Warning # There are no model in new file for %s..." % geo
                continue
            # -
            mc.transferAttributes(
                UVgeo, geo, pos=0, nml=0, uvs=2, col=0, spa=5, sus="map1", tus="map1", sm=0, fuv=0, clb=1
            )
            # -
            print "# Result # Copyed UV %s -> %s" % (UVgeo, geo)

            # - delete history
            RemoveUVWasteNode.delUVTransferAttributesNode(geo)

        self.progressBar.setMaximum(1)
        self.progressBar.setValue(0)
        self.btn_replace.setText("Replace")
        # - remove refrence
        mc.file(f, rr=True)
    def on_btn_Copy_clicked(self, clicked=None):
        if clicked == None: return
        src_bs = str(self.let_Src.text())
        dst_bs = str(self.let_Dst.text())
        src_index = self.listView_Src.selectedIndexes() or None
        dst_index = self.listView_Dst.selectedIndexes() or None

        #- blendShape exists ?
        if not mc.objExists(src_bs):
            return

        if not mc.objExists(dst_bs):
            return

        #- is blendShape ?
        if mc.nodeType(src_bs) != 'blendShape':
            return

        if mc.nodeType(dst_bs) != 'blendShape':
            return

        #- index has selected?
        if src_index is None:
            return
        else:
            src_index = src_index[0].row()

        if dst_index is None:
            return
        else:
            dst_index = dst_index[0].row()

        #- is one blendShape and one attr?
        if src_bs == dst_bs and src_index == dst_index:
            return

        Vtxes = mc.polyEvaluate(mc.blendShape(src_bs, q=True, g=True), v=True)
        self.progressBar.setMaximum(Vtxes)

        for i in range(Vtxes):
            #-
            if src_index == 0:
                value = mc.getAttr('%s.it[0].bw[%d]' % (src_bs, i))
            else:
                value = mc.getAttr('%s.it[0].itg[%d].tw[%d]' %
                                   (src_bs, src_index - 1, i))

            #-
            if dst_index == 0:
                mc.setAttr('%s.it[0].bw[%d]' % (dst_bs, i), value)
            else:
                mc.setAttr(
                    '%s.it[0].itg[%d].tw[%d]' % (dst_bs, dst_index - 1, i),
                    value)

            self.progressBar.setValue(i)
            self.progressLabel.setText('%d%%' %
                                       mathTool.setRange(0, Vtxes, 0, 100, i))

        #- reset UI
        self.progressBar.setMaximum(1)
        self.progressBar.setValue(0)
        self.progressLabel.setText('0%')
Ejemplo n.º 3
0
 def on_progressBar_valueChanged(self, value):
     realV = int(mathTool.setRange(self.progressBar.minimum(), self.progressBar.maximum(), 0, 100, value))
     self.label_progress.setText('%d%%'%realV)
 def on_btn_Copy_clicked(self, clicked=None):
     if clicked == None:return
     src_bs = str(self.let_Src.text())
     dst_bs = str(self.let_Dst.text())
     src_index = self.listView_Src.selectedIndexes() or None
     dst_index = self.listView_Dst.selectedIndexes() or None
     
     #- blendShape exists ?
     if not mc.objExists(src_bs):
         return
     
     if not mc.objExists(dst_bs):
         return
     
     #- is blendShape ?
     if mc.nodeType(src_bs) != 'blendShape':
         return
     
     if mc.nodeType(dst_bs) != 'blendShape':
         return
     
     #- index has selected?
     if src_index is None:
         return
     else:
         src_index = src_index[0].row()
     
     
     if dst_index is None:
         return
     else:
         dst_index = dst_index[0].row()
     
     #- is one blendShape and one attr?
     if src_bs == dst_bs and src_index == dst_index:
         return
     
     
     Vtxes = mc.polyEvaluate(mc.blendShape(src_bs, q=True, g=True), v=True)
     self.progressBar.setMaximum(Vtxes)
     
     
     for i in range(Vtxes):
         #-
         if src_index == 0:
             value = mc.getAttr('%s.it[0].bw[%d]'%(src_bs, i))
         else:
             value = mc.getAttr('%s.it[0].itg[%d].tw[%d]'%(src_bs, src_index-1, i))
         
         #-
         if dst_index == 0:
             mc.setAttr('%s.it[0].bw[%d]'%(dst_bs, i), value)
         else:
             mc.setAttr('%s.it[0].itg[%d].tw[%d]'%(dst_bs, dst_index-1, i), value)
         
         
         self.progressBar.setValue(i)
         self.progressLabel.setText('%d%%'%mathTool.setRange(0, Vtxes, 0, 100, i))
     
     #- reset UI
     self.progressBar.setMaximum(1)
     self.progressBar.setValue(0)
     self.progressLabel.setText('0%')
Ejemplo n.º 5
0
 def on_progressBar_valueChanged(self, value):
     realV = int(
         mathTool.setRange(self.progressBar.minimum(),
                           self.progressBar.maximum(), 0, 100, value))
     self.label_progress.setText('%d%%' % realV)
Ejemplo n.º 6
0
    def on_btn_replace_clicked(self, clicked=None):
        if clicked == None: return

        polyGeometry = mc.ls(type='mesh')
        if not polyGeometry:
            print '# Error # No polyGon geometrys...',
            return
        polyGeometry = (mc.listRelatives(polyGeometry, p=True))
        polyGeometry = dict.fromkeys(polyGeometry).keys()

        selectIndexes = self.listView.selectedIndexes()
        if not selectIndexes:
            print '# Error # - You must select a model file...',
            return
        index = selectIndexes[0].row()
        modelPath = self.asset_data[index]

        if not uiTool.warning(
                message=
                'Model\'s UV will be replaced, and it can not to undo !!!\nContinue ? ?'
        ):
            return

        #- refrence
        f = mc.file(modelPath, r=True, namespace='UV')

        self.progressBar.setMaximum(len(polyGeometry))
        for i, geo in enumerate(polyGeometry):
            self.progressBar.setValue(i)
            self.btn_replace.setText(
                '%d%%' % mathTool.setRange(0, len(polyGeometry), 0, 100, i))

            realName = re.search('\w+$', geo).group()
            UVgeo = 'UV:%s' % realName
            if not mc.objExists(UVgeo):
                print '# Warning # There are no model in new file for %s...' % geo
                continue
            #-
            mc.transferAttributes(UVgeo,
                                  geo,
                                  pos=0,
                                  nml=0,
                                  uvs=2,
                                  col=0,
                                  spa=5,
                                  sus="map1",
                                  tus="map1",
                                  sm=0,
                                  fuv=0,
                                  clb=1)
            #-
            print '# Result # Copyed UV %s -> %s' % (UVgeo, geo)

            #- delete history
            RemoveUVWasteNode.delUVTransferAttributesNode(geo)

        self.progressBar.setMaximum(1)
        self.progressBar.setValue(0)
        self.btn_replace.setText('Replace')
        #- remove refrence
        mc.file(f, rr=True)