【问题标题】:cmds.move issue Maya GUI (PYTHON)cmds.move 问题 Maya GUI (PYTHON)
【发布时间】:2017-03-23 12:44:56
【问题描述】:
import maya.cmds as cmds

def shapeTool ():
    ram = 'RenamerWin'
    if cmds.window(ram, q = True, exists =True):
        cmds.deleteUI(ram)

    ram = cmds.window("RenamerWin",t = "Shape Tool", w=300, h=300)
    cmds.columnLayout(adj = True)
    cmds.separator(h=20)
    cmds.text("Welcome to the Shape Creator")
    cmds.separator(h=20)


    cubW = cmds.intSliderGrp(l = "Width", min =0, max = 10, field = True)
    cubH = cmds.intSliderGrp(l = "Height", min =0, max = 10, field = True)
    cubD = cmds.intSliderGrp(l = "Depth", min =0, max = 10, field = True)

    cubX = cmds.intSliderGrp(l = "Translate X axis", field = True)
    cubY = cmds.intSliderGrp(l = "Translate Y axis", field = True)
    cubZ = cmds.intSliderGrp(l = "Translate Z axis", field = True)

    def myCube(_):
        myCubeWidth = cmds.intSliderGrp(cubW , q= True,value =True)
        myCubeHeight = cmds.intSliderGrp(cubH , q= True,value =True) 
        myCubeDepth = cmds.intSliderGrp(cubD , q= True,value =True)
        myCubeMoveX = cmds.intSliderGrp(cubMX , q= True,value =True)
        myCubeMoveY = cmds.intSliderGrp(cubMY , q= True,value =True)
        myCubeMoveZ = cmds.intSliderGrp(cubMZ , q= True,value =True)
        cmds.polyCube(w=myCubeWidth,h=myCubeHeight,d=myCubeDepth , n = "myCube")
        cmds.move(myCubeMoveX, x=True )
        cmds.move(myCubeMoveY, x=True )
        cmds.move(myCubeMoveZ, x=True )

    cmds.button(l = "Create a Cube",c=myCube)

    cmds.showWindow(ram)

shapeTool()

你好,

我不明白为什么这不起作用...当我注释掉 Move 时,GUI 工作,所以它必须与此有关。 如果有人有任何想法,请告诉我

谢谢。

【问题讨论】:

  • 您应该在描述中包含错误,以便人们更有效地提供帮助。

标签: python user-interface maya


【解决方案1】:

基本上,如果你想在所有三个方向上移动,那么你需要通过 xyz=True 并且你有一个错字也不是 cubMX 只是 cubX ?.. 这是一个稍微修改过的版本,它正在工作

import maya.cmds as cmds

def shapeTool ():
    ram = 'RenamerWin'
    if cmds.window(ram, q = True, exists =True):
        cmds.deleteUI(ram)

    ram = cmds.window("RenamerWin",t = "Shape Tool", w=300, h=300)
    cmds.columnLayout(adj = True)
    cmds.separator(h=20)
    cmds.text("Welcome to the Shape Creator")
    cmds.separator(h=20)


    cubW = cmds.intSliderGrp(l = "Width", min =0, max = 10, field = True)
    cubH = cmds.intSliderGrp(l = "Height", min =0, max = 10, field = True)
    cubD = cmds.intSliderGrp(l = "Depth", min =0, max = 10, field = True)

    cubX = cmds.intSliderGrp(l = "Translate X axis", field = True)
    cubY = cmds.intSliderGrp(l = "Translate Y axis", field = True)
    cubZ = cmds.intSliderGrp(l = "Translate Z axis", field = True)

    def myCube(_):
        myCubeWidth = cmds.intSliderGrp(cubW , q= True,value =True)
        myCubeHeight = cmds.intSliderGrp(cubH , q= True,value =True) 
        myCubeDepth = cmds.intSliderGrp(cubD , q= True,value =True)
        myCubeMoveX = cmds.intSliderGrp(cubX , q= True,value =True)
        myCubeMoveY = cmds.intSliderGrp(cubY , q= True,value =True)
        myCubeMoveZ = cmds.intSliderGrp(cubZ , q= True,value =True)
        print myCubeMoveZ, myCubeMoveY, myCubeMoveX
        cmds.polyCube(w=myCubeWidth,h=myCubeHeight,d=myCubeDepth , n = "myCube")
        cmds.move(myCubeMoveX,myCubeMoveY,myCubeMoveZ,  xyz=True )

    cmds.button(l = "Create a Cube",c=myCube)

    cmds.showWindow(ram)

shapeTool()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多