maya Pythonを使ってシェーダーを割り当てる
pythonを使用して
三角ポリゴン、多角形ポリゴンを色分けしようと思いスクリプトを書いてみました。
三角ポリゴンが黄色、多角形が青色です。
import maya.cmds as mc;
material_Tri = mc.shadingNode('lambert',n='Tri',asShader=True);
mc.setAttr('Tri.color',1.0,1.0,0.0,type='double3');
material_Qua = mc.shadingNode('lambert',n='Qua',asShader=True);
mc.setAttr('Qua.color',0.2,0.2,0.2,type='double3');
material_Nsided = mc.shadingNode('lambert',n='Nsided',asShader=True);
mc.setAttr('Nsided.color',0.0,0.0,1.0,type='double3');
if mc.window("PolyFinderWindow",exists=True):
mc.deleteUI("PolyFinderWindow")
Create_Window = mc.window("PolyFinderWindow",t="PolyFinder",w=30,h=50,s=True,mnb=True,mxb=True);
mc.columnLayout(adj=True);
mc.button(l="Tri",c="SetTri()");
mc.separator(h=10);
mc.button(l="Nsided",c="SetNsided()");
mc.separator(h=10);
mc.button(l="Clear",c="SetClear()")
mc.showWindow(Create_Window);
def SetTri():
mc.polySelectConstraint(t=0x008,m=3,sz=1)
mc.hyperShade(a='Tri')
mc.sets(e=True,fe='Tri.SG')
def SetNsided():
mc.polySelectConstraint(t=0x008,m=3,sz=3)
mc.hyperShade(a='Nsided')
mc.sets(e=True,fe='Nsided.SG')
def SetClear():
mc.hyperShade(a='Qua')
mc.sets(e=True,fe='Qua.SG')