mayapython开关_Maya Python:选项菜单选择与按钮

我对Maya中的python还不熟悉,我正在尝试构建一个可以生成形状并对其进行变换的UI。我认为问题在于ObjectCreation函数,但我不确定。到目前为止,我得到的是:import maya.cmds as cmds

#check to see if window exists

if cmds.window("UserInterface", exists = True):

cmds.deleteUI("UserInterface")

#create actual window

UIwindow = cmds.window("UserInterface", title = "User Interface Test", w = 500, h = 700, mnb = False, mxb = False, sizeable = False)

mainLayout = cmds.columnLayout(w = 300, h =500)

def SceneClear(*args):

cmds.delete(all=True, c=True) #Deletes all objects in scene

cmds.button(label = "Reset", w = 300, command=SceneClear)

polygonSelectMenu = cmds.optionMenu(w = 250, label = "Polygon Selection:")

cmds.menuItem(label = " ")

cmds.menuItem(label = "Sphere")

cmds.menuItem(label = "Cube")

cmds.menuItem(label = "Cylinder")

cmds.menuItem(label = "Cone")

def ObjectCreation(*args):

if polygonSelectMenu.index == 2: #tried referring to index

ma.polySphere(name = "Sphere")

elif polygonSelectMenu == "Cube":

ma.polyCube(name = "Cube")

elif polygonSelectMenu == "Cylinder":

ma.polyCylinder(name = "Cylinder")

elif polygonSelectMenu == "Cone":

ma.polyCone(name = "Cone")

cmds.button(label = "Create", w = 200, command=ObjectCreation)

def DeleteButton(*args):

cmds.delete()

cmds.button(label = "Delete", w = 200, command=DeleteButton)#Deletes selected object

cmds.showWindow(UIwindow) #shows window

我要做的是让用户从选项菜单中选择一个选项,然后按“创建”按钮生成该形状。我试着用名字和索引来指代它,但我不知道我遗漏了什么。就像我说的,我是python新手,所以当我自己尝试寻找答案时,我什么也找不到,而当我确实找到了类似的东西时,我无法理解它。另外,由于某些原因,SceneClear功能/重置按钮似乎不起作用,因此如果有答案,请告诉我。在

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值