试图做到这一点
import maya.cmds as mc
def firstFace():
FaceToSel = 'first' def allFace():
FaceToSel = 'all'
def execute():
if FaceToSel == 'first':
print Yes
elif FaceToSel == 'all':
print No
def ui():
if mc.window('face_Select', exists = True):
mc.deleteUI('face_Select')
FaceWin = mc.window('face_Select', mxb = False)
mc.columnLayout( adjustableColumn = True )
mc.intFieldGrp( 'numberOfFaces', label = 'Number Of Facess', value1 = 10 )
ButtonOne = mc.radioButtonGrp( label='Type', labelArray3=['TopFaces', 'Allfaces'], numberOfRadioButtons = 2, onCommand1 = 'firstFace()', onCommand2 = 'lastFace()')
mc.button( label = 'Select faces', command = 'execute()', align = 'center', aop = True)
mc.showWindow('face_Select')
ui()
答案 0 :(得分:0)
首先问一个问题。 然后提供带缩进的代码,在逗号处添加“是”和“否”,检查您的函数是否存在定义的def,具有正确数据的命令标志,这将更容易使您得到答案.....
这是一个工作代码,如果您需要更多解释,请查看有关我已回答的ui的问题
How to use a slider value in calculations?
import maya.cmds as mc
from functools import partial
def execute(FaceToSel, *args):
option = mc.radioButtonGrp(FaceToSel, q=True, select=True)
if option == 1:
print True
elif option == 2:
print False
def ui():
if mc.window('face_Select', exists = True):
mc.deleteUI('face_Select')
FaceWin = mc.window('face_Select', mxb = False)
mc.columnLayout( adjustableColumn = True )
mc.intFieldGrp( 'numberOfFaces', label = 'Number Of Facess', value1 = 10 )
ButtonOne = mc.radioButtonGrp( label='Type', labelArray2=['TopFaces', 'Allfaces'], numberOfRadioButtons = 2, select=1)
mc.button( label = 'Select faces', command = partial(execute, ButtonOne), align = 'center', aop = True)
mc.showWindow('face_Select')
ui()