.
世の中にたくさんある、Maya さまのワイヤカラー設定ツール
どれもこれも、微妙に自分が求める使い勝手と違ったり、自分にとっては無駄に高機能だったり。 なぜか俺の環境で動いてくれないものもある。
やっぱ書くしかないのかしら。
XSI 時代にも書いた ワイカラさん が、現代に蘇る。
Python:
# -*- coding: utf-8 -*-
# ワイカラさん for Maya v0.1
import pymel.core as pm
def colSetter( target, colIndex, valOutliner, valRGB ):
if target != None :
if colIndex == -1 :
pm.setAttr( target + ".overrideEnabled", 0 )
pm.setAttr( target + ".overrideColor", 0 )
pm.setAttr( target + ".useOutlinerColor", 0 )
#pm.setAttr( target + ".outlinerColor", 0, 0, 0 )
else :
colRGB = pm.colorIndex( colIndex, q=1 )
pm.setAttr( target + ".overrideEnabled", 1 )
pm.setAttr( target + ".overrideColor", colIndex )
if valRGB == True:
pm.setAttr( target + ".overrideRGBColors", 1 )
pm.setAttr( target + ".overrideColorRGB", colRGB[0], colRGB[1], colRGB[2] )
if valOutliner == True :
pm.setAttr( target + ".useOutlinerColor", 1 )
pm.setAttr( target + ".outlinerColor", colRGB[0], colRGB[1], colRGB[2] )
def setWireColor( colIndex ):
valTransf = pm.checkBox( cbTransf, q=1, value=1 )
valShape = pm.checkBox( cbShape, q=1, value=1 )
valOutliner=pm.checkBox( cbOutliner, q=1, value=1 )
valRGB = pm.checkBox( cbRGB, q=1, value=1 )
valDesel = pm.checkBox( cbDesel, q=1, value=1 )
sels = pm.selected()
for obj in sels:
shp = obj.getShape()
if valTransf == True : colSetter( obj, colIndex, valOutliner, valRGB )
if valShape == True : colSetter( shp, colIndex, valOutliner, valRGB )
if valDesel == True : pm.select( clear=1 )
windowName = u"ワイからさん for Maya"
if pm.window( windowName, exists=True ) : pm.deleteUI( windowName )
waikaraWin = pm.window( windowName )
pm.columnLayout( adjustableColumn=1 )
pm.frameLayout( cll=1, cl=0, mw=4, mh=3, lv=0, bv=1)
pm.rowColumnLayout( numberOfColumns= 16 )
for i in range(31):
colRGB = pm.colorIndex( i+1, q=1 )
pm.nodeIconButton( style="textOnly", bgc=( colRGB[0], colRGB[1], colRGB[2] ),
marginWidth=1, marginHeight=1, width=20, height=18,
command = "setWireColor(%d)" % (i+1)
)
pm.nodeIconButton( style="textOnly", bgc=( 0.4, 0.4, 0.4 ), label="K",
marginWidth=1, marginHeight=1, width=20, height=18,
command="setWireColor(%d)" % -1 )
pm.setParent( ".." )
pm.rowColumnLayout( numberOfColumns= 5 )
cbTransf = pm.checkBox( label="Transform", v=1 )
cbShape = pm.checkBox( label="Shape", v=1 )
cbOutliner=pm.checkBox( label="Outliner", v=1 )
cbRGB = pm.checkBox( label="RGB" )
cbDesel = pm.checkBox( label="Delesect", v=1 )
pm.showWindow( waikaraWin )
ダウンロード wikaraSan_v01.py (2.7K)
とりあえず、最低限必要なものだけ書いた。
これをひな型として、まずは運用してみて、必ず不満点が出てくるから、ちょっとずつ改良していく。 昔からそうやって自分用のツールを書いてきた。
低レベルなものばかりだけどね。 そのスジの人に見られたら、プッと笑われそう。 でもいいの。 俺様の需要を満たしてくれているから。 俺の需要に合わせて書いたツール以上に俺の需要を満たしてくれるものはないのです。
しかし、Maya さまのワイヤカラーのしくみ、めんどくせえなあ。 XSI のは、普通にオブジェクトごとに1つ色を持っているだけだったんだけどなあ。
Maya さまのワイヤカラーは、トランスフォームノード、シェイプノードにそれぞれ色を持っていて、かつ、アウトライナ表示用の色も別に持っている。
しかもそれぞれ、インデクスカラーと RGB カラーと持っていて、でもアウトライナ用のカラーは RGB しかない。
そしてどうやら、ハイパーグラフ内では、RGBカラーの表示ができない。インデクスカラーしか反応してくれない。
そしてインデクスカラーの種類が全31色と、どうにも足りない。 いい塩梅の色が多ければ31色もあれば十分なのだが、なにやら半端で見づらい色が多い。
そしてまだ調査不足で仕組みを理解できていないのだが、上記のトランスフォームノードとシェイプノードの Drawing overrides で決める色
以外に、
Display > Wireframe Color などというメニューも存在する。
なんぞこれ。
この Wireframe Color よりも、
トランスフォームノードやシェイプノードの Drawing Overrides で決めた色の方が優先されるように見える。 そちらに色が入っている時(=Enable Overrides がオフになっている時、またはオンになっていてもインデクスカラーが0 の時)は、この Wireframe Color が反映されないから。
また、
この Wireframe Color の方で決めた色は、どこにデータを持っているのか、いまだに発見できていない。 アトリビュートエディタで探してみたが、見つからない。 どこに情報しまってあるんだ。 スクリプトエディタで Echo All にすれば見つかるかな。 めんどくせえなw
なんでこんな複雑な仕組みにしたのでしょう?
なんか、トラップをいっぱい仕込まれているような気が?
わざとやってんですか?
Maya さま?
おかげで仕事は進まず、
問題対処の能力が高まります。
本当にありがとうございますMayaさま。
.
最近のコメント