First of all, this seems to be a great place to learn more about programming. I've written a maya python script, where both functions work, I'm having trouble getting the UI button to call the superExtrude() function, though. The first function does the geometric mesh manipulations and the second one should produce the UI for the user inputs:
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, columnWidth=[(1,120),(2,120)], columnOffset=[1,"right",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, style="none")
cmds.separator(height=10, style="none")
cmds.separator(height=10, style="none")
cmds.button(label="Apply", command=superExtrude(extrScaleVal, extrDistVal))
cmds.showWindow()
extrWindow()
I'm pretty new to python and maya scripting, so any help would be greatly appreciated. :)