CG News

modoのランダム ワイヤーフレーム カラー スクリプト

modoのワイヤーフレーム色にランダムに色を設定するスクリプトが公開されています。バウンディングボックススレッショルドと組み合わせるとMaxっぽくて便利かもしれません。
https://community.foundry.com/discuss/post/1151471

スクリプトはファイルに保存してUIのボタンに割り当てるか、スクリプトエディターから実行することができます。

 

import modo, random

def random01():
    # Convert random 0-1 into scring
    return (str(random.random())+" ")

def setColor(item):
    try:
        # add draw package
        lx.eval("!item.draw mode:add type:locator item:%s" % item.id)
        # Set color to user
        lx.eval("item.channel name:locator$wireOptions value:user item:%s" % item.id)
    except RuntimeError:
        # Item alread has package
        pass
    # Randomize color
    color = ("{"+random01()+random01()+random01()+"}")
    # Set Color
    lx.eval("item.channel name:locator$wireColor value:%s item:%s" % (color, item.id))

# Get the active scene
scene = modo.Scene()
# Get selected objects of type mesh
items = scene.selectedByType(lx.symbol.sITYPE_MESH)
packAdded = False
# if selection contains meshes
if items:
    for item in items:
        print item
        setColor(item)
else: # Otherwise Do all
    for item in scene.iterItemsFast(lx.symbol.sITYPE_MESH):
        setColor(item)
        print item

 

 

コメントを残す