No More Retake

3DCG屋さん向けTips&Referenceサイト

メニュー

Houdini:Python memo Part02

Houdini python memo!  ver 15.0.244.16

 はじめに

import hou

#/objに"geo1"という名前のgeoノードを作る。
oGeo = hou.node('/obj').createNode('geo','geo1')

#/obj/geo1を取得
oNode = hou.node('/obj/geo1')

#選択したノードを取得(配列で)
oNodes = hou.selectedNodes()
oNode = oNodes[0]

#使えるメソッド一覧
dir(oNode)

#メソッドの使い方を調べる
help(oNode.parm)

# name取得
oNode.name()

# Path取得
oNode.path()

#現在のグローバルノード
print hou.pwd()
#現行のノードを変更する
hou.cd("/obj")

 

球を作成 その1

import hou

geo = hou.node('/obj').createNode('geo', 'sphere',0)
geo.createNode('sphere')

 

球を作成 その2(作って消して色つけて)

import hou

hou.cd("/obj)
node = hou.pwd()
geo = node.createNode('geo')
geo.node('file1').destroy()
geo.createNode('sphere')
#ついでに色もつけてみる
c=hou.Color([1,0,0])
geo.setColor(c)

HoudiniPython_06


 

 ノードのコネクション

oGeo = hou.node("obj").createNode('geo','geo1',0)

#Sphere(SOP)を作成
oSphe= oGeo.createNode('sphere', 'sphere')

#Box(SOP)をoSpheの出力に作成する
oBox = oSphe.createOutputNode('box', 'box')
#File(SOP)をoSpheの入力に作成する
oFile = oSphe.createInputNode(0,'file', 'file')
#Transform(SOP)をoBoxの出力に作成する
oXform = oBox.createOutputNode('xform', 'xform')

#null(SOP)を作って、入力につなぐ
oNull = oGeo.createNode('null', 'null')
oNull.setInput(0,oXform)

#入力のリストを取得する
inlist = oBox.inputs()
#出力のリストを取得する
outlist = oBox.outputs()

 

パラメータとか

import hou

geo = hou.node('/obj').createNode('sphere', 'sphere')
n = hou.node(/obj/geo1)

# パラメータ取得
tx = n.parm("tx")

#取得したパラメータを評価
tx.eval()

#指定したフレームのパラメータ値を取得
tx.evalAtFrame(10)

#取得したパラメータに値をセット
tx.set(0.2)

#エクスプレッション追加
tx.setExpression("$FF")

#キーフレーム全消し
tx.deleteAllKeyframes()

#名前を指定してパラメータの値をセット
n.setParms({"tx":1, "ty":2, "tz":3})

#パラメータを全部表示してみる
for i in n.parms():
   print i.name()


 

「例:1」含むノードをリストで取得

import hou
n = hou.selectedNodes()

children = n.children()

for child in children:
     print child.name()

 

「例:2」 例1と同様の機能を関数定義

def childrenOfNode(node):
     result = []
     for c in node.children():
         result += childrenOfNode(c)
         result.append(c)
     return result

 

 

ポップアップメッセージ

hou.ui.displayMessage("hoge")

HoudiniPython_07


ノードのローカル変数

lvar('TX') #$TXのこと

 

ランダムとかノイズとか

hou.hmath.rand(lvar("PT")) #ポイント番号からランダム値を生成

hou.hmath.noise1d([lvar("TX"),lvar("TY"),lvar("TZ")])
hou.hmath.noise1d([lvar("TX"),lvar("TY"),lvar("TZ"), time()]) #時間で変化

 

 

Newtwork Editor上の座標を取得

p = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
print p.selectPosition()

Newtwork Editor上の座標を指定

oGeo = hou.node('obj').createNode('geo','sphere',0)
oSphere = oGeo.createNode('sphere')
oSphere.setPosition([1,1])

Newtwork Editor上の座標を指定して配置

p = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
pos = p.selectPosition()
oSphere = p.pwd().createNode('sphere')
oSphere.setPosition(pos)

 


 

最後にPythonじゃないけど・・・。

ShelfをTabMenuから使えるようにする

TabMenueに表示させたいShelfのアイコンを右クリック->Edit Tool…
ContextタブのNetwork PaneでObjやSOP等のカテゴリを指定する。

Python_01

 

続く?

Houdini:Python memo Part01へ


参考


関連記事

  1. 2019.04.09

    Houdini:Damping V&W

コメントをお待ちしております

このサイトについて

3DCG Tipsサイト。Houdiniの記事が多めです。

RSS

follow us in feedly

Archives

  • 2024 (1)
  • 2023 (2)
  • 2022 (9)
  • 2021 (14)
  • 2020 (46)
  • 2019 (17)
  • 2018 (33)
  • 2017 (29)
  • 2016 (36)
  • 2015 (64)
  • 2014 (54)
  • 2013 (60)
  • 2012 (55)

スポンサードリンク

言語切り替え

  • English (United States)
  • 日本語

スポンサードリンク

言語切り替え

  • English (United States)
  • 日本語

Houdiniを使えるようになる本


Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): Failed to enable crypto in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(http://api.facebook.com/restserver.php?method=links.getStats&urls=http%3A%2F%2Fnomoreretake.net%2F2016%2F03%2F01%2Fhoudinipython-memo-part02%2F): failed to open stream: operation failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(): Failed to enable crypto in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132

Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http%3A%2F%2Fnomoreretake.net%2F2016%2F03%2F01%2Fhoudinipython-memo-part02%2F): failed to open stream: operation failed in /usr/home/nomorere/nomoreretake.net/wordpress/wp-content/themes/n1-custom/functions/social.php on line 132