Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created November 3, 2023 11:08
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save BigRoy/df2c56c32b83b85d7d056e7c7d056346 to your computer and use it in GitHub Desktop.
Houdini Python LOPs node add simple 360 Y-axis rotation on a prim
from pxr import UsdGeom, Usd
node = hou.pwd()
stage = node.editableStage()
path = "/cube"
prim = stage.GetPrimAtPath(path)
start = node.evalParm("start")
end = node.evalParm("end")
xform = UsdGeom.Xformable(prim)
# Clear all transforms
xform.ClearXformOpOrder()
# Do not inherit parent transformations
xform.SetResetXformStack(True)
# Add the rotate Y spin operation
rotate = xform.AddRotateYOp()
rotate.Set(0, time=start)
rotate.Set(360, time=end+1)
@BigRoy
Copy link
Author

BigRoy commented Nov 3, 2023

Or have it run over the last modified prims of the input node.

from pxr import UsdGeom, Usd

node = hou.pwd()
stage = node.editableStage()

for prim_path in node.inputPrims(0):
    prim = stage.GetPrimAtPath(prim_path)

    start = node.evalParm("start")
    end = node.evalParm("end")
    
    xform = UsdGeom.Xformable(prim)
    # Clear all transforms
    xform.ClearXformOpOrder()
    # Do not inherit parent transformations
    xform.SetResetXformStack(True)
    # Add the rotate Y spin operation
    rotate = xform.AddRotateYOp()
    rotate.Set(0, time=start)
    rotate.Set(360, time=end+1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment