第一个maya的python脚本,比较简单,实现的功能是改变选中物体线框的颜色.[python] view plain copy
1. import maya.cmds as py
2. import sys
3. if py.window('pyColor',ex=True):
4. py.deleteUI('pyColor',wnd=True)
5. version = sys.version
6. print version
7. def resetButton(arg):
8. print 'reset was pushed.'
9. mySel = py.ls(sl=True)
10. if len(mySel)==0:
11. py.confirmDialog(t='提示',m='No object is selected!',b='OK')
12. else:
13. py.pickWalk(d='down')
14. mySel = py.ls(sl=True)
15. for item in mySel:
16. py.setAttr (item+".overrideEnabled",0)
17. py.setAttr (item+".overrideColor",0)18.
19. def note(arg):
20. mySel = py.ls(sl=True)
21. if len(mySel)==0:
22. py.confirmDialog(t='提示',m='No object is selected!',b='OK')
23. else:
24. colorObject(arg)
25.
26. def colorObject(arg):
27. value = py.textField('input',q=True,tx=True)
28. py.pickWalk(d='down')
29. mySel = py.ls(sl=True)
30. for mySel in mySel:
31. py.setAttr (mySel+".overrideEnabled",1)
32. py.setAttr (mySel+".overrideColor",int(value))
33.
34.
35. if py.window('pyColor',ex=True):
36. py.deleteUI('pyColor',wnd=True)
37. py.window('pyColor',t='colorCurve')
38. py.columnLayout(adj=True)
39. py.text(l='请输入0到31的整数:',fn='fixedWidthFont',bgc=(0,0,0))
40. py.textField('input',tx='0',bgc=(0,0,0))
41. py.button(l='着色',c=note)
42. py.button(l='reset',c=resetButton)
43. py.showWindow()
结果截图:
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标常用软件之Maya频道!