I have this code in python that has to query three radiobuttons created for a window in maya..This is the code I have so far, I can query the sliders but I don't get how to query radiobuttons..
import maya.cmds as cmds
#def function1(value):
def function1(value1,value2):
print(value1)
def function2(value):
print(value)
def createUI():
cmds.window("Window")
cmds.columnLayout( adjustableColumn=True )
value1 = cmds.intSliderGrp(label='number of moons', minValue=4, maxValue=20, value=12, field=True)
value2 = cmds.intSliderGrp(label='Distance from parent to child', minValue=5, maxValue=40, value=20, field=True)
DirectionControl = cmds.radioCollection()
Direction0 = cmds.radioButton( label='Front')
Direction1 = cmds.radioButton( label='Back')
Direction2 = cmds.radioButton( label='Random')
cmds.radioCollection( DirectionControl, edit=True, select=Direction0 )
cmds.button(label = "OK", command = lambda *args: function1(cmds.intSliderGrp(value1, query=True, value=True), cmds.intSliderGrp(value2, query=True, value=True),cmds.radioButtonGrp(Direction1, query=True, value=True)))
cmds.showWindow()
createUI()
#
This line:
cmds.button(label = "OK", command = lambda *args: function1(cmds.intSliderGrp(value1, query=True, value=True), cmds.intSliderGrp(value2, query=True, value=True),cmds.radioButtonGrp(Direction1, query=True, value=True)))
works if we remove the statement related to the radiobuttons..
First thing, putting so much stuff in a lambda function don't make any sense. You need to consider writing code in a better way so the guy who going maintain it won't get mad at you :P. And more importantly next time when you come back to your code it will make much more sense.
Second thing, you need to consider reading maya command docs because radionCollection and radioGroup are not same and radioCollection won't return any value as you expected.
I have a bit clean'd up version of you code.
import maya.cmds as cmds
from functools import partial
#def function1(value):
def function1(value1,value2):
print(value1)
def function2(value):
print(value)
def createUI():
myWindow = "SomeWindow"
if maya.cmds.window(myWindow,ex=True):
maya.cmds.deleteUI(myWindow)
cmds.window(myWindow)
cmds.columnLayout( adjustableColumn=True )
value1 = cmds.intSliderGrp(label='number of moons', minValue=4, maxValue=20, value=12, field=True)
value2 = cmds.intSliderGrp(label='Distance from parent to child', minValue=5, maxValue=40, value=20, field=True)
DirectionControl = cmds.radioCollection()
Direction0 = cmds.radioButton( label='Front')
Direction1 = cmds.radioButton( label='Back')
Direction2 = cmds.radioButton( label='Random')
DirectionControl = cmds.radioCollection( DirectionControl, edit=True, select=Direction0 )
cmds.button(label = "OK", command = partial(passValue, value1, value2, DirectionControl))
cmds.setParent("..")
cmds.showWindow()
def passValue(value1, value2, DirectionControl, *args):
intValOne = cmds.intSliderGrp(value1, query=True, value=True)
intValTwo = cmds.intSliderGrp(value2, query=True, value=True)
radioCol = cmds.radioCollection(DirectionControl, query=True, sl=True)
getSelectRadioVal = cmds.radioButton(radioCol, query=True, label=True)
function1(intValOne, intValTwo)
function2(getSelectRadioVal)
createUI()
Hope this help