My first module is pretty simple, just create a soccer ball and then extrude it twice as the picture shows below. But I did learn lots of new maya commands and understand Module deeper. Here is the script:
"""This script prints some information and creates a spike ball."""
import maya.cmds
def addSpikes(obj):
"""This function adds spikes to a polygon object."""
try: polycount = maya.cmds.polyEvaluate(obj, face=True)
except: raise
for i in range(0, polycount):
face = '%s.f[%s]'%(obj, i)//遍历obj的所有face
maya.cmds.polyExtrudeFacet(face, ltz=1, ch=0)//第一次extrude
maya.cmds.polyExtrudeFacet(face, ltz=1, ch=0, ls=[.1,.1,.1])//第二次extrude 缩小为上一次的0.1倍
maya.cmds.polySoftEdge(obj, a=180, ch=0)
maya.cmds.select(obj)
print('module name: %s'%__name__)
print('globals:')
for k in globals().keys(): print('\t%s'%k)
addSpikes(maya.cmds.polyPrimitive(ch=0)[0])//创建一个soccer ball
Result:
我觉着
ReplyDeleteimport maya.cmds as cmd
会大大减少你的 cmd 前缀 O(∩_∩)O哈哈~