リクエストがあったのでVOP SOPのような処理をPython SOPで行う方法を書いてみる。
とりあえず、ノード構成はこんな感じでやってみる。

■Python SOP
myDeformerはPython SOP
Python SOPはデフォルトの状態だと以下のようにコードが記述されている。
###########################################
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
###########################################
hou.pwd()はPython SOP自身のノードオブジェクトを返す。
Node.geometry()は自身に入力されたhou.Geometry型のジオメトリオブジェクトを返す。
geometryの中にはPointやEdgeやPrimitive型のオブジェクトが含まれており、実際に形状や色を変更する際は、これらのコンポーネントオブジェクトを取得して操作する。
■コンポーネントの取得
■Pointリストの取得
points = geo.points()
■Primitiveリストの取得
prims = geo.prims()
それぞれのコンポーネントに一律の処理を行うには?
・単純にforループで回す
for point in points:
position = point.position()
for prim in prims:
verts = prim.vertices()
・iterPointsを使う(generatorの使用、こっちのほうがメモリ効率良さそう)
for point in geo.iterPoints():
position = point.position()
■pointを移動してみるサンプル
###########################################
import math
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
for point in geo.points():
initPosition = point.position()
pointIndex = point.number()
radian = math.radians( pointIndex )
displacement = hou.Vector3( [ 0 , math.sin( radian * 10 ) , 0 ] )
newPosition = initPosition + displacement
point.setPosition( newPosition )
###########################################
・Gridを変形

・Sphereを変形

■各オブジェクトのリファレンスマニュアル
各オブジェクトの使い方は以下のマニュアルを参照すべし
・hou.Geometry
http://sidefx.jp/doc/hom/hou/Geometry.html
・hou.Point
http://sidefx.jp/doc/hom/hou/Point.html
・hou.Prim
http://sidefx.jp/doc/hom/hou/Prim.html