def pairConfirmed(self): """ !@Brief This function make sure that privious condition "self.lockPair" and "self.lockRetopo" are set to True """ rules = [self.lockPair == True, self.lockRetopo == True] if rules: self.coutureCore.manualPairMatching([ self.qLineGarment.text(), self.qLinePattern.text(), self.qLineRetopo.text() ], self) else: cm.create("You need to select a garment, a pattern and a retopo", " OK !", None, None)
def gozSelPattern(self): """ !@Brief Allow user to export the pattern with Goz """ pm.select(cl=True) selGarment = pm.select("|soloPatternObjectsGRP|pattern_%s" % (self.qLineGarment.text())) import maya.mel as mel try: mel.eval( """source "C:/Users/Public/Pixologic/GoZApps/Maya/GoZBrushFromMaya.mel" """ ) except: cm.create( """It seems like GoZ is not installed on your Maya\n You will have to export manually :( """, "Ok, I got it !")
def selectSolo(self, type): """ !@Brief Use user selection to define a mesh for each step of couture and file the appropriate QLineEdit @param type: String, There's four type of selection "garment","retopo" """ # Run basic check on the user selection selection = pm.selected(fl=True) if selection == []: cm.create("Nothing selected", " OK !", None, None) return if len(selection) > 1: cm.create("Too many objects selected", " OK !", None, None) else: if type == "garment": if pm.objExists("soloGarmentObjectGRP"): pm.delete("soloGarmentObjectGRP") sg = "" if pm.objExists('Garment_Shader'): sg = pm.PyNode("Garment_SG") pm.sets(sg, edit=1, forceElement=selection[0]) self.soloGarment = selection[0] self.qLineGarment.setText("%s" % selection[0]) soloGrp = pm.group(n="soloGarmentObjectGRP", em=True) selection[0].setParent(soloGrp) else: if pm.objExists("soloGarmentObjectGRP"): pm.delete("soloGarmentObjectGRP") sg = "" if pm.objExists('Retopo_Shader'): sg = pm.PyNode("Retopo_SG") pm.sets(sg, edit=1, forceElement=selection[0]) self.soloRetopo = selection[0] self.qLineRetopo.setText("%s" % selection[0]) soloGrp = pm.group(n="soloRetopoObjectGRP", em=True) selection[0].setParent(soloGrp)
def browseMesh(self, type): """ !@Brief Allow user to import and select a mesh from a file @param type: String, There's four type of selection "garment","retopo" """ exportPath = self.dataNode.getExportPath() singleFilter = "*.obj;;*.fbx;;*.ma;;*.mb" if exportPath == "": selection = pm.fileDialog2(fm=1, fileFilter=singleFilter, dialogStyle=2, cap="Import object", rf=True) else: selection = pm.fileDialog2(fm=1, fileFilter=singleFilter, dialogStyle=2, cap="Import object", rf=True, dir=exportPath) if selection == None: return if type == "garment": if pm.objExists("soloGarmentObjectGRP"): pm.delete("soloGarmentObjectGRP") importedNode = pm.importFile(selection[0], i=True, returnNewNodes=True, groupReference=True, groupName="soloGarmentObjectGRP") grp = pm.PyNode("soloGarmentObjectGRP") grpChildren = pm.listRelatives(grp, c=True) if len(grpChildren) > 1: cm.create("Too many objects imported", " OK !", None, None) return sg = "" if pm.objExists('Garment_Shader'): sg = pm.PyNode("Garment_SG") pm.sets(sg, edit=1, forceElement=grpChildren[0]) else: if pm.objExists("soloRetopoObjectGRP"): pm.delete("soloRetopoObjectGRP") importedNode = pm.importFile(selection[0], i=True, returnNewNodes=True, groupReference=True, groupName="soloRetopoObjectGRP") grp = pm.PyNode("soloRetopoObjectGRP") grpChildren = pm.listRelatives(grp, c=True) if len(grpChildren) > 1: cm.create("Too many objects imported", " OK !", None, None) return sg = "" if pm.objExists('Retopo_Shader'): sg = pm.PyNode("Retopo_SG") pm.sets(sg, edit=1, forceElement=grpChildren[0]) geoTest = data.testGeo(grpChildren) for object in geoTest[1]: object.setParent(world=True) pm.delete(object) if len(geoTest[0]) == 1: try: separate = pm.polySeparate(grpChildren[0]) for object in separate: pm.delete(object) cm.create("You can import a single mesh only", "Ok") return except: ### Output the name of the mesh in the appropriate textflied ### if type == "garment": self.soloGarment = grpChildren[0] self.qLineGarment.setText("%s" % grpChildren[0]) elif type == "retopo": self.soloRetopo = grpChildren[0] self.qLineRetopo.setText("%s" % grpChildren[0]) pass elif len(geoTest[0]) > 1: pm.delete(grpChildren) cm.create("You can import a single mesh only", "Ok") return
def selectPiece(self, type): """ !@Brief Use user selection to define a mesh for each step of couture and file the appropriate QLineEdit @param type: String, There's four type of selection "garment", "pattern","retopo" """ selection = pm.selected(fl=True) # run basic safety checks on the user selection if selection == []: cm.create("Nothing selected", " OK !", None, None) return if len(selection) > 1: cm.create("Too many objects selected", " OK !", None, None) return # test if selection is a geometry testResults = data.testGeo(selection) if len(testResults[1]) > 0: cm.create("You have selected a non polygonal object", " OK !", None, None) return else: if type == "garment": # Check if selected mesh is not a exhisting pattern or retopo arr = ['pattern_', 'retopo_'] if any(c in selection[0].longName() for c in arr): cm.create("You didn't select a garment mesh", " OK !", None, None) return if self.lockPair == False: if selection[0].longName( ) in self.coutureCore.patternDic.keys(): # Check if a mesh with the same name is already loaded and paired in Couture if self.coutureCore.patternDic[selection[0].longName( )][1] != "" and self.coutureCore.patternDic[ selection[0].longName()][1] != "None": cm.create( "This garment already have a pattern and a retopo.", " OK !", None, None) return self.statusGarment.setPixmap(self.tickGreenlIcon) self.qLineGarment.setText("%s" % selection[0].longName()) self.qLineGarment.setReadOnly(True) self.qLinePattern.setText(self.coutureCore.patternDic[ selection[0].longName()][0]) self.qLinePattern.setReadOnly(True) self.statusPattern.setPixmap(self.tickGreenlIcon) self.lockPair = True else: cm.create( "This garment has not been loaded in the tool previously, use the " + " button", " OK !", None, None) self.statusGarment.setPixmap(self.xRedIcon) else: return elif type == "pattern": print "pattern" if self.lockPair == False: if selection[0] in [ x for v in self.coutureCore.patternDic.values() for x in v ]: # Check if a mesh with the same name is already loaded and paired in Couture print data.longNameEdit("pattern", selection[0].longName(), "pattern", "garment") print self.coutureCore.patternDic[data.longNameEdit( "pattern", selection[0].longName(), "pattern", "garment")] if self.coutureCore.patternDic[data.longNameEdit( "pattern", selection[0].longName(), "pattern", "garment")][1] != "None": cm.create( "This garment already have a pattern and a retopo", " OK !", None, None) return self.qLinePattern.setText("%s" % selection[0].longName()) self.qLinePattern.setReadOnly(True) self.statusPattern.setPixmap(self.tickGreenlIcon) self.qLineGarment.setText( data.longNameEdit("pattern", selection[0].longName(), "pattern", "garment")) self.qLineGarment.setReadOnly(True) self.statusGarment.setPixmap(self.tickGreenlIcon) self.lockPair = True else: cm.create( "This garment has not been loaded in the tool previously, use the " + " button", " OK !", None, None) self.statusPattern.setPixmap(self.xRedIcon) else: return elif type == "retopo": if self.lockRetopo == False: self.qLineRetopo.setText("%s" % selection[0]) self.qLineRetopo.setReadOnly(True) self.statusRetopo.setPixmap(self.tickGreenlIcon) self.lockRetopo = True else: return