def btnCheGradClicked (self): current_languge = cfgl.configLoader()[14] SelectionData = gen_func.checkSelection() SelectedShapes = SelectionData[0] if len(SelectedShapes) > 0: CurrentShaderData = getCurrentShader(SelectedShapes) self.PreviousShadersArray = CurrentShaderData[0] self.ObjectsWithShadersArray = CurrentShaderData[1] if checkShaderIntegrity("04") == True: changeCheckerTexture ("checker_gradient", SelectedShapes) else: createCheckerMaterial("04") changeCheckerTexture ("checker_gradient", SelectedShapes) self.checkerRoutineFunctions(SelectedShapes) conclusion_text = conclusion.uvOperationConclusion (current_languge, "assign_grad_checker") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("info", "Gradient checker was assigned!") else: conclusion_text = conclusion.noSelection(current_languge, "assign_grad_checker") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("warn", "Cant assign checker. Please select mesh object in Object Mode.")
def btnRemCheckClicked (self): current_languge = cfgl.configLoader()[14] for i in range(len(self.PreviousShadersArray)): try: cmds.sets(self.ObjectsWithShadersArray[i], e=True, forceElement = self.PreviousShadersArray[i]) except: pass self.PreviousShadersArray = [] self.ObjectsWithShadersArray = [] print "" print "Delete Checker Shaders:" #delete all checkers for i in range(1,5): Type = "0" + str(i) DeletedElementsCount = 0 try: cmds.delete('pt_shading_group_type_' + Type) DeletedElementsCount += 1 except: pass try: cmds.delete('pt_checker_shader_' + Type) DeletedElementsCount += 1 except: pass try: cmds.delete('pt_checker_texture_' + Type) DeletedElementsCount += 1 except: pass try: cmds.delete('pt_2dTexture_' + Type) DeletedElementsCount += 1 except: pass if DeletedElementsCount > 0: print "PolygonTools. pt_shading_group_type_" + Type, "was removed!" #disable buttons self.btnRemCheck.setEnabled(False) self.gboxCheckRes.setEnabled(False) print "" conclusion_text = conclusion.uvOperationConclusion (current_languge, "delete_checker") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("info", "Remove pt-chaders operation complete!")
def btnViewUVPressed(self): current_languge = cfgl.configLoader()[14] SelectionData = gen_func.checkSelection() SelectedShapes = SelectionData[0] #delete colorsets for i in range(len(SelectedShapes)): CurrentColorSet = cmds.polyColorSet(SelectedShapes[i], q=True, currentColorSet=True) if CurrentColorSet != None: cmds.polyColorSet (SelectedShapes[i], delete=True ) #create and delete file if len(SelectedShapes) > 0: #if pressed if self.btnViewUV.isChecked() == True: #delete shader if cmds.objExists('pt_uv_shader'): DelUVShaders() self.btnViewUV.setText("Show UV") #assign prev mat for i in range(len(self.PreviousShadersArray)): try: cmds.sets(self.ObjectsWithShadersArray[i], e=True, forceElement = self.PreviousShadersArray[i]) except: pass self.showInfo("info", "UV Snapshot was removed.") else: try: #get previous shader CurrentShaderData = getCurrentShader(SelectedShapes) self.PreviousShadersArray = CurrentShaderData[0] self.ObjectsWithShadersArray = CurrentShaderData[1] #remove old uv if exist if cmds.objExists('pt_uv_shader') == True: DelUVShaders() self.btnViewUV.setText("Show UV") #create and showe shader createUVTexture(SelectedShapes) cmds.sets(SelectedShapes, e=True, forceElement='pt_shading_group_uv') cmds.select(SelectedShapes) self.btnViewUV.setText("Hide UV") conclusion_text = conclusion.uvOperationConclusion (current_languge, "assign_uv") self.txtbrowUVConclusion.setHtml(conclusion_text) self.showInfo("info", "UV Snapshot was assigned to objects.") except: self.showInfo ("warn", "Can't create UV Snapshot.") else: conclusion_text = conclusion.noSelection(current_languge, "show_uv") self.txtbrowUVConclusion.setHtml(conclusion_text) #If nothing selected self.btnViewUV.setChecked(True) #delete shader if not selected if cmds.objExists('pt_uv_shader'): DelUVShaders() self.btnViewUV.setText("Show UV") self.showInfo ("info", "UV Snapshot was removed.") else: self.showInfo ("warn", "Please select something. Mesh object for example...")