MotionBuilder Forum
Welcome to Autodesk’s MotionBuilder Forums. Share your knowledge, ask questions, and explore popular MotionBuilder topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Querying Checkbox Value???

1 REPLY 1
SOLVED
Reply
Message 1 of 2
robotProdigy
669 Views, 1 Reply

Querying Checkbox Value???

I need to make a dialog box with lots of checkboxes and text fields, and collect their values upon hitting an apply button.  I’m new to scripting in MotionBuilder, and am having trouble querying the value of checkboxes.  Here is my sample code.  I made this as small as possible.  What supposed to happen is, if you hit the button, it will log the select state of the checkbox in the python editor.  If you run this, you’ll notice that the select state always logs False regardless if the checkbox is selected or not.  The 8th line is where it's not working.

 

Help VERY much appreciated.

 

 

 

from pyfbsdk import *
from functools import partial


def show_textbox_val(cb, control, event):
    cb.Refresh(True)
    print("cb.Caption = %s" % cb.Caption)
    print("cb.Selected = %s" % cb.Selected)
    print("cb.Enabled = %s" % cb.Selected)



def PopulateLayout(mainLyt):

    VBox = FBVBoxLayout()

    #Region
    x = FBAddRegionParam(5, FBAttachType.kFBAttachLeft, "")
    y = FBAddRegionParam(5, FBAttachType.kFBAttachTop, "")
    w = FBAddRegionParam(5, FBAttachType.kFBAttachRight, "")
    h = FBAddRegionParam(5, FBAttachType.kFBAttachBottom, "")
    mainLyt.AddRegion("main", "main", x, y, w, h)
    mainLyt.SetControl("main", VBox)


    #Checkbox
    cb = FBButton()
    cb.Caption = "a caption"
    cb.Style = FBButtonStyle.kFBCheckbox


    #Button
    bt = FBButton()
    bt.Caption = "Apply"
    bt.OnClick.Add(partial(show_textbox_val, cb))

    VBox.Add(cb, 20)
    VBox.Add(bt, 20)


def CreateBoxShotTool():
    global t
    t = FBCreateUniqueTool("Ugh")
    t.StartSizeX = 350
    t.StartSizeY = 200
    t.StartPosX = 500
    PopulateLayout(t)
    ShowTool(t)

CreateBoxShotTool()

 

Thanks,

Paul

1 REPLY 1
Message 2 of 2
robotProdigy
in reply to: robotProdigy

I’ll answer my own question.  It’s the FBButton.state attribute.

 

So line 8 could have been replaced with

print("cb.State = %s" % cb.State)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report