I feel so silly asking this question. I'm sure it has a simple answer, but I really don't know what it is.

Here's a bareboned example of what I'm trying to do.

Enter the values, press the button, create a cube. The problem is, I can't create a cube with the updated information in my fields. I'd like to avoid doing "mc.intField("n", query = True, value = True)" in the makeCube section if I can, but I'm not sure how else I can get the updated values in my fields.

This is one of the things that the vanilla cmds ui stuff is really not that good for. However, if you want to use this approach the simplest answer is to just make a second function that prepares your data and calls the relevent function. In fact this is exactly how a lot of internal MEL commands work...
add something like:
def prepMakeCube(*args):
name = mc.textField("n", query = True, text = True)
width = mc.intField("w", query = True, value = True)
height = mc.intField("h", query = True, value = True)
makeCube(name,width,height)
then just change your doButton to:
doButton = mc.button(label = "Create Cube!", command = prepMakeCube )

PozestStar

12-08-2012, 04:23 PM

Thanks so much for this. It was really driving me crazy.

CGTalk Moderation

12-08-2012, 04:23 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.