Maya Python GUI旋转球体

时间:2017-03-11 19:18:13

标签: python user-interface maya face

(新编码器)我试图创建一个基本的GUI,允许用户创建一个球体并选择半径和旋转。我设法做了半径然而我有点卡住旋转; xform命令。就像我说的半径是工作但不是旋转。

目前看到GUI:https://gyazo.com/5f3626443334da1abdecaea434fe4e03

任何帮助表示赞赏:)

继承我的代码:

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)

    sphR = cmds.intSliderGrp(l = "Radius", min =0, max = 10, field = True)
    sphA = cmds.intSliderGrp(l = "Rotate", field = True)

    def mySphere(_):
        mySphereRadius = cmds.intSliderGrp(sphR , q= True,value =True)
        mySphereRotate = cmds.intSliderGrp(sphA , q= True,value =True)
        finalSphere = cmds.polySphere(r=mySphereRadius, n = "mySphere")
        finalSphere = cmds.xform( r=True, ro=(0, 90, 0) )

    cmds.button(l = "Create a Sphere",c=mySphere)
    cmds.showWindow(ram)

shapeTool()

1 个答案:

答案 0 :(得分:0)

  1. 您的旋转功能将始终将新球体旋转90度Y.这是意图吗?它会忽略旋转滑块。
  2. 如上所述,它会旋转您创建的球体 - 但为了清楚起见并了解您的实际情况,您可能希望这样做:

    finalSphere,finalShape = cmds.polySphere(r = mySphereRadius,n =" mySphere")   cmds.xform(finalSphere,r = True,ro =(0,mySphereRotate,0))