命令移动发布Maya GUI(PYTHON)

2024-04-25 22:54:36 发布

您现在位置:Python中文网/ 问答频道 /正文

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就可以工作了,所以必须这样做。 如果有人有什么想法,请告诉我

谢谢。你知道吗


Tags: truefieldmovevaluedefminmaxtranslate
1条回答
网友
1楼 · 发布于 2024-04-25 22:54:36

基本上,如果你想在所有三个方向上移动,那么你需要传递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()

相关问题 更多 >