選択とかもある程度児童で選ぶべるような関数も書いておきます。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
・オブジェクト選択 | |
geo = hou.node('/obj/geo1') | |
・その中にボックスノード作成 | |
geo.createNode('box', 'box1') | |
・その中のsopノードを取得 | |
boxnode = geo.node('/obj/box1') | |
・このボックスのパラメータにアクセス | |
boxnode.parm('cx') | |
・文字列ならこっち!? | |
boxnode.parm('cx').eval() | |
・パラメータの値変更 | |
boxnode.parm('cx').deleteAllKeyframes() ※すでにエクスプレッションが入ってるときはこれ必要 | |
boxnode.parm('cx').set(0) | |
・パラメータにエクスプレッション | |
boxnode.parm('cx').deleteAllKeyframes() ※すでにエクスプレッションが入ってるときはこれ必要 | |
boxnode.parm('cx').setExpression('ch("../box1/ty")') | |
・名前をちゃんとつけてれば、これで一括変更 | |
for num in range(1,101): | |
box = geo.node('box%d'%num) | |
if box is not None: | |
box .parm('cx').set(num*10) | |
・マテリアルノード一括選択 | |
materials = geo.node('material1').type().instances() | |
for y in hou.selectedNodes(): | |
y.setSelected(False,True) | |
for material in materials: | |
material.setSelected(True) | |
※material.setSelected(TrueTrue)はほかの選択したものを解除する。 | |
はじめのループで現在選択状態のものをすべて未選択に。 | |
・特定の名前をつけたノードを一括選択 | |
for y in hou.selectedNodes(): | |
y.setSelected(False,True) | |
for num in range(1,101): | |
box = geo.node('box%d'%num) | |
if box is not None: | |
box .setSelected(True) | |
・ボックスノード(box1~box10)を一括でmergeに接続 | |
for num in range(1,11): | |
box= geo.node('box%d'%num) | |
if box not None: | |
geo.node('merge1').insertInput(num-1, box) | |
・ボックスノードのインプットに接続されるノードを作る | |
boxnode.createInputNode(0,'switch', 'switch1') |
反復が繰り返されて、大量にノードができちゃったときは、一括変更できてとても便利。