Python を使用して Maya 内でカスタム UI を作成していますが、次の行で発生するこのエラーで立ち往生しています。
parts = button2.split(",") # NameError: global name 'button2' is not defined
これが私のスクリプトです:
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()
基本的に、私のスクリプトは、何かを行うボタンを内部に持つ UI を作成しようとしています。この場合、ユーザーが一連の座標をキー入力するテキストフィールド ボタンを作成しようとしています。ロケータ ベースのカーブは、指定された一連の座標に従って作成されます。ただし、デフォルトのカーブを作成するボタンしか作成できませんでした。人が与える座標を考慮して特定の曲線を出力するボタンを作成する方法を誰か教えてもらえますか?