mayaでpythonを使用して選択したオブジェクトのワイヤフレームの色を変更
1539 ワード
最初のmayaのpythonスクリプトは、比較的簡単で、選択した物体のワイヤフレームの色を変える機能を実現する.
結果:
import maya.cmds as py
import sys
if py.window('pyColor',ex=True):
py.deleteUI('pyColor',wnd=True)
version = sys.version
print version
def resetButton(arg):
print 'reset was pushed.'
mySel = py.ls(sl=True)
if len(mySel)==0:
py.confirmDialog(t=' ',m='No object is selected!',b='OK')
else:
py.pickWalk(d='down')
mySel = py.ls(sl=True)
for item in mySel:
py.setAttr (item+".overrideEnabled",0)
py.setAttr (item+".overrideColor",0)
def note(arg):
mySel = py.ls(sl=True)
if len(mySel)==0:
py.confirmDialog(t=' ',m='No object is selected!',b='OK')
else:
colorObject(arg)
def colorObject(arg):
value = py.textField('input',q=True,tx=True)
py.pickWalk(d='down')
mySel = py.ls(sl=True)
for mySel in mySel:
py.setAttr (mySel+".overrideEnabled",1)
py.setAttr (mySel+".overrideColor",int(value))
if py.window('pyColor',ex=True):
py.deleteUI('pyColor',wnd=True)
py.window('pyColor',t='colorCurve')
py.columnLayout(adj=True)
py.text(l=' 0 31 :',fn='fixedWidthFont',bgc=(0,0,0))
py.textField('input',tx='0',bgc=(0,0,0))
py.button(l=' ',c=note)
py.button(l='reset',c=resetButton)
py.showWindow()
結果: