简体   繁体   English

cmds.move问题Maya GUI(PYTHON)

[英]cmds.move issue Maya GUI (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()

Hi there, 嗨,您好,

I dont uderstand why this isnt working... When I comment out Move, then the GUI works so it must be to do with that. 我不明白为什么这行不通...当我注释掉Move时,GUI起作用了,因此必须与此相关。 If anyone has any ideas please let me know 如果有人有任何想法请告诉我

Thanks. 谢谢。

Basically if you want to move in all three direction then you need pass xyz=True and you had a typo also not cubMX just cubX ?.. Here is a slight modified version which is working 基本上,如果您想在所有三个方向上移动,则需要传递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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM