在Maya和Python中使用形状滑块

在Maya和Python中使用形状滑块,python,maya,Python,Maya,我是Python新手,我有下面的代码,我尝试使用下面的滑块来显示颜色,翻译,旋转和缩放,以显示我在代码中的形状 有没有办法用这些滑块控制所有的形状?我似乎不明白我已经尽了我所能了 任何帮助都将不胜感激,谢谢 #Importing all Maya commands to Python import maya.cmds as cmds from functools import partial class CreateUI(): def __init__(self): w

我是Python新手,我有下面的代码,我尝试使用下面的滑块来显示
颜色
翻译
旋转
缩放
,以显示我在代码中的形状

有没有办法用这些滑块控制所有的形状?我似乎不明白我已经尽了我所能了

任何帮助都将不胜感激,谢谢

#Importing all Maya commands to Python
import maya.cmds as cmds
from functools import partial

class CreateUI():
    def __init__(self):
        windowID = "myWindowID"

        if cmds.window(windowID, exists=True):
            cmds.deleteUI(windowID)

#-----------------------------------------------Layout of Interface 

        masterWindow = cmds.window(windowID, title="User Interface", w=500, h=800, sizeable=False, resizeToFitChildren=True)
        ShapeLayout = cmds.rowColumnLayout(parent=masterWindow, numberOfColumns=1, columnOffset=[(2,"left",0)])



#-----------------------------------------------Shape Functions       

#Functions for creating shapes        
        def mySphere(*args):
            cmds.polySphere()

        def myCube(*args):
            cmds.polyCube()

        def myCylinder(*args):
            cmds.polyCylinder()

        def myCone(*args):
            cmds.polyCone()

        def myTorus(*args):
            cmds.polyTorus()

        def myPlane(*args):
            cmds.polyPlane()

        def myDelete(*args):
            cmds.select()
            cmds.delete()

#Gets rid of any shapes in the scene so that the user doesn't have to every time the UI is launched or the sript is run
        ShapeList = cmds.ls("mySphere*", "myCube*", "myCylinder*", "myCone*", "myTorus*", "myPlane*","pSphere*", "pCube*", "pCylinder*", "pCone*", "pTorus*", "pPlane*")
        if len(ShapeList)>0:
            cmds.delete(ShapeList)

#-----------------------------------------------Shape Buttons         

#Buttons for creating shapes    
        cmds.button(label="Sphere", command=mySphere)
        cmds.button(label="Cube", command=myCube)
        cmds.button(label="Cylinder", command=myCylinder)
        cmds.button(label="Cone", command=myCone)
        cmds.button(label="Torus", command=myTorus)
        cmds.button(label="Plane", command=myPlane)
        cmds.button(label="Delete", command=myDelete)

        #COLOUR
        cmds.separator(h=20, style="none")
        cmds.colorSliderGrp('blockColour',label="Colour", hsv=(120, 1, 1))
        cmds.separator(h=20, style="none")

        #TRANSLATE
        TranslateX = cmds.intSliderGrp('TX',label="Translate X ", field=True, min=1, max=100, value=0)  
        TranslateY = cmds.intSliderGrp('TY',label="Translate Y ", field=True, min=1, max=100, value=0)
        TranslateZ = cmds.intSliderGrp('TZ',label="Translate Z ", field=True, min=1, max=100, value=0)
        cmds.separator(h=20, style="none")

        #ROTATE
        RotateX = cmds.intSliderGrp('RX',label="Rotate X ", field=True, min=1, max=100, value=0)  
        RotateY = cmds.intSliderGrp('RY',label="Rotate Y ", field=True, min=1, max=100, value=0)
        RotateZ = cmds.intSliderGrp('RZ',label="Rotate Z ", field=True, min=1, max=100, value=0)
        cmds.separator(h=20, style="none")

        #SCALE
        ScaleX = cmds.intSliderGrp('SX',label="Scale X ", field=True, min=1, max=100, value=0)  
        ScaleY = cmds.intSliderGrp('SY',label="Scale Y ", field=True, min=1, max=100, value=0)
        ScaleZ = cmds.intSliderGrp('SZ',label="Scale Z ", field=True, min=1, max=100, value=0)



        cmds.showWindow(windowID)
ui=CreateUI()        

看看你的另一篇文章,重复一篇文章不会给你更多的视觉效果