tags:

views:

119

answers:

0

Hi all, I am creating a custom UI inside maya using python. I encountered some errors, Hope you guys could help. I attached my script below. Basically my script is trying to create a UI with buttons inside that do stuffs. In this case, I am trying to create a textfield button which the user keys in a set of coordinates and the locator based curve is created according to the set of coordinates given. However, I could only manage to create a button that creates a default curve. Can some one tell me how to go about creating a button that takes into consideration what coordinates a person gives and outputs the specific curve? I really got no idea how and I tried many times and it doesn't work.

Thanks!

import maya.cmds as cmds

def createMyLayout():
    window = cmds.window(widthHeight=(1000, 600), title="lalala",   resizeToFitChildren=1)
    cmds.rowLayout("button1, button2, button3", numberOfColumns=5)

    cmds.columnLayout(adjustableColumn=True, columnAlign="center", rowSpacing=10)

    button2 = cmds.textFieldButtonGrp(label="LocatorCurve",
                                    text="Please key in your coordinates",
                                    changeCommand=edit_curve,
                                    buttonLabel="Execute",
                                    buttonCommand=locator_curve)
    cmds.setParent(menu=True)

    cmds.showWindow(window)

def locator_curve(*args):
    # Coordinates of the locator-shaped curve.
    crv = cmds.curve(degree=1,
                 point=[(1, 0, 0),
                        (-1, 0, 0),
                        (0, 0, 0),
                        (0, 1, 0),
                        (0, -1, 0),
                        (0, 0, 0),
                        (0, 0, 1),
                        (0, 0, -1),
                        (0, 0, 0)])


    return crv

def edit_curve(*args):
    parts = button2.split(",")
    print parts


createMyLayout()