角色控制器上的属性切换(GUI)

在这里插入图片描述
不需要选中控制器,插件是为了一键切换场景中的所有角色头发显示模式。

# -*- coding: utf-8 -*-
import maya.cmds as mc

from PySide.QtGui import *
from PySide.QtCore import *

import maya.OpenMayaUI as omui
import shiboken

def getMayaWindow():
	return shiboken.wrapInstance(long(omui.MQtUtil.mainWindow()), QMainWindow)
	
	
class switch_button_gui(QDialog):

	def __init__(self,parent = None):
		
		super(switch_button_gui,self).__init__(parent)
		
		self.setParent(getMayaWindow())
		self.setWindowFlags(Qt.Window)
		
		btn_Mode = QPushButton('Model')
		btn_Fur = QPushButton('Fur')
		
		
		h_box = QVBoxLayout()
		
		h_box.addWidget(btn_Mode)
		h_box.addWidget(btn_Fur)
		
		self.setLayout(h_box)
		self.resize(QSize(200,100))  
		
		self.setWindowTitle(u'MXS_switch') 
		
		btn_Mode.clicked.connect(switch_mod_type) 
		
		btn_Fur.clicked.connect(switch_fur_type)  
		

def switch_mod_type():

	get_all_head_control = mc.ls("*FKHead_M","*:FKHead_M","*:*:FKHead_M")

	for per_conversion in get_all_head_control:
		
		mc.setAttr("%s.Hair_Conversion"%per_conversion,0)

def switch_fur_type():

	get_all_head_control = mc.ls("*FKHead_M","*:FKHead_M","*:*:FKHead_M")

	for per_conversion in get_all_head_control:
		
		mc.setAttr("%s.Hair_Conversion"%per_conversion,1)
		
		
		
if __name__ == '__main__':
    try:
        MXS_switch_window.close()
        
    except:
        pass
    
    MXS_switch_window = switch_button_gui()
    
    MXS_switch_window.show() 

猜你喜欢

转载自blog.csdn.net/qq_36338099/article/details/89876125