首先,这似乎是一个学习更多编程的好地方.我编写了一个maya python脚本,其中两个函数都有效,但我无法通过UI按钮来调用superExtrude()函数.第一个函数执行几何网格操作,第二个函数应该为用户输入生成UI:
import maya.cmds as cmds def superExtrude(extrScale, extrDist): """Loops through a list of selected meshes and extrudes all of the mesh faces to produce a polygon frame, based on existing mesh tesselations""" myObjectLt = cmds.ls(selection=True) for i in range(len(myObjectLt)): numFaces = cmds.polyEvaluate(face=True) item = myObjectLt[i] + ".f[:]" cmds.select(clear=True) cmds.select(item, replace=True) #extrude by scale cmds.polyExtrudeFacet(constructionHistory=True, keepFacesTogether=False, localScaleX=extrScale, localScaleY=extrScale, localScaleZ=extrScale) selFaces = cmds.ls(selection=True) cmds.delete(selFaces) #extrude by height cmds.select(item, replace=True) cmds.polyExtrudeFacet(constructionHistory=True, keepFacesTogether=True, localTranslateZ=extrDist) def extrWindow(): """Creates the user interface UI for the user input of the extrusion scale and height""" windowID = "superExtrWindow" if cmds.window(windowID, exists=True): cmds.deleteUI(windowID) cmds.window(windowID, title="SuperExtrude", sizeable=False, resizeToFitChildren=True) cmds.rowColumnLayout(numberOfColumns=2, columnright",3]) cmds.text(label="Extrusion Scale:") extrScaleVal = cmds.floatField(text=0.9) cmds.text(label="Extrusion Height:") extrDistVal = cmds.floatField(text=-0.3) cmds.separator(height=10, ) cmds.separator(height=10, ) cmds.separator(height=10, ) cmds.button(label="Apply", command=superExtrude(extrScaleVal, extrDistVal)) cmds.showWindow() extrWindow()
我是python和maya脚本的新手,所以任何帮助都会非常感激.:)