cqbarca Posted June 25, 2015 Share Posted June 25, 2015 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! Quote Link to comment Share on other sites More sharing options...
Robert Posted June 26, 2015 Share Posted June 26, 2015 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. Quote Link to comment Share on other sites More sharing options...
cqbarca Posted June 26, 2015 Author Share Posted June 26, 2015 thanks Robert! It works perfectly! I was trying to load the whole sequence up front; the key is to find the current frame and load the corresponding file. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.