Jump to content

keyframe an attribute of Point


Recommended Posts

Hi,

 

I'm trying to bringing in simulation data (txt files) at discrete times into Houdini through python. The information the files contain is just position vector and velocity vector. 

 

Thanks to the tutorial here http://www.deborahrfowler.com/PythonResources/PythonHoudiniExamples.html, I'vemanaged to import file at a certain time by creating a point and set attributes. e.g:

        point = geo.createPoint()
        point.setPosition((px,py,pz))
        point.setAttribValue(vel, (vx,vy,vz))
 
My question is -- how do I do that for a frame range? e.g. I have file.1.txt, file2.txt, file3.txt etc, and wanted to import them to frame 1, 2, 3 respectively. Is keyframing the best way to do it?
 
I found there's a way to set keyframe:
        key = hou.Keyframe(1)
        sphere.parm("v").setKeyframe(key)
 
But since point is not an geometry, how do I access its velocity attribute?
 
thanks!
 
Link to comment
Share on other sites

I got a sort of similar setup in a python SOP to load a sequence of .txt files. The code that loads the file is:

filepath = hou.pwd().parm('file').eval()

Takes the file from the "file" parameter that I added to the SOP. In this parameter you can just enter your file with `$F` as the sequence number to load a new version.

For example:

C:/Users/robert/MosselProject/PDE_`$F`.txt

For attributes you first have to create them:

velocity = geo.addAttrib(hou.attribType.Point,"velocity",0.0)

And afterwards you assign the values you read from your .txt file with point.setAttribValue.

When your points are created you can use the attributes like any other through expressions or in wrangle nodes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...