Get vertex world position at time?

   1088   4   0
User Avatar
Member
14 posts
Joined: Dec. 2017
Offline
Hi,

I'm struggeling to find a way to get the world position of a selected point at a specific time.

Any suggestions?

# Psuedo code:
frame = 100
for p in selected_points:
    print(p.worldPositionAtFrame(frame))
User Avatar
Member
8231 posts
Joined: Sept. 2011
Offline
I'm not sure you can get an attribute value at a certain time in python, you need to use a timeshift sop to cook a node at a certain time. Alternatively, you could use CHOPs to cook a sop for all time and then query the chop value at a time.
User Avatar
Member
355 posts
Joined: Nov. 2013
Offline
in vex there's optransform https://www.sidefx.com/docs/houdini/vex/functions/optransform.html [www.sidefx.com]
Edited by antc - Sept. 11, 2024 11:20:43
User Avatar
Member
14 posts
Joined: Dec. 2017
Offline
Thanks for the reply and suggestions. I'm quite new to python scripting in Houdini (and really Houdini overall) so forgive me if I'm asking the obvious.

1.If I were to go the CHOPS way, would it work something like this:
- Fetch the object (fetch node?)
- Add a TimeShift node and set the wanted frame
- Read the value of a point (index) somehow?

2. In Houdini, is it suggested that you via Python add nodes, extract a values and then delete nodes? Instead of doing things directly with the API?

3. Any suggestions how to get the selected point indexes that I can then use in CHOPS?

Thanks
/Simon
User Avatar
Member
14 posts
Joined: Dec. 2017
Offline
I haven't tried CHOPS yet, but here's a sample code that seems to work.
However, it only works if the TimeShift node exist, not if I create it via python. Any idea?

import toolutils
import nodesearch
import hou
import os

def get_points():

    selection = toolutils.sceneViewer().selectGeometry()
    node = selection.nodes()[0]
    selection = selection.selectionStrings()
    selection = list(selection)

    x = node.geometry().globPoints(selection[0])
    return (x, node)

points, node = get_points()

context = hou.node(os.path.dirname(node.path()))

# If I have a already existing node everything works.
#ts = hou.node("/obj/geo1/timeshift1")

# This timeshift does not work.
ts = context.createNode("timeshift")
ts.setInput(0,node)
ts.parm("frame").deleteAllKeyframes()
ts.setDisplayFlag(True)
ts.setRenderFlag(True)

for frame in range(1,25):
    ts.parm("frame").set(frame)
    
    for p in points:
        print(p.position())

#ts.destroy()
  • Quick Links