View Full Version : Check box grp

11 November 2011, 03:47 AM
I dont understand why I have to write the query value in seperate lines instead of one?

p, li { white-space: pre-wrap; } if cmds.window('myWin', exists=True):
def pCube (obj):
if cmds.checkBoxGrp (chBox, query=True, value1=True):
if cmds.checkBoxGrp (chBox, query=True, value2=True):

window = cmds.window( title='myWin', iconName='Win', widthHeight=(500, 110) )

cmds.columnLayout( adjustableColumn=True )
chBox = cmds.checkBoxGrp( numberOfCheckBoxes=2, label='Blahh', labelArray2=['Ahha','Hey'])
cmds.button( label='Button', command=(pCube))
cmds.setParent( '..' )
cmds.showWindow( window )

This works just fine. But if use this line.
def pCube (obj):
if cmds.checkBoxGrp (chBox, query=True, value1=True, value2=True):

Then the second check box will not work. What am I doing worng?

11 November 2011, 09:42 AM
That's the way the query works - you can query either a single value like you do with "value1=True", which returns a boolean, or you can query two of the values with "valueArray2=True" which will return [boolean, boolean] or all with valueArray4 etc.

11 November 2011, 09:48 AM
any `if` statement has to be simply true, or false (in boolean logic terms). You cannot query somethng that returns two, possibly different values. If box 1 is on (true) and box 2 is off (false) how can that return a single true or false answer for an `if` statement?
I assume you're expecting it to only return true if both boxes are on? this is logical `and` and you must always be explicit and unambiguous when it comes to logic.


11 November 2011, 03:35 PM
Perhaps the valueArray2 option is what you want. That returns boolean, boolean.

<* Wes *>

11 November 2011, 10:26 PM
In the case of IF statements, as previously stated, it is just simple programming logic. What you are describing is in fact this:

def pCube (obj):
if (cmds.checkBoxGrp (chBox, query=True, value1=True)) and (cmds.checkBoxGrp (chBox, query=True, value2=True)):

11 November 2011, 11:09 PM
thanks guys.

CGTalk Moderation
11 November 2011, 11:09 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.