Barad-Dur Posted November 15, 2008 Share Posted November 15, 2008 Hi guys, If I had a .txt file in this format: 17.813 58.693 12.84 18.322 57.538 12.101 19.493 56.83 12.766 19.731 55.651 12.514 18.724 57.964 10.686 17.703 58.857 10.022 where first column is X, second is Y and third is Z how would I go about getting Houdini to read that data and generate a point cloud that I could use to copy geometry to etc. The above data are just a portion from a massive file of like 5000 points or so. It would seem that this would be a good spot to get Houdini to simply read a file from a file SOP and dump these XYZ data into an Add SOP or something akin to that. Any advice on this would be most appreciated. Thanks David Quote Link to comment Share on other sites More sharing options...
graham Posted November 15, 2008 Share Posted November 15, 2008 (edited) This is something that could easily be accomplished using a simple Python Sop. Something like this should work as long as you have added a File parameter named 'file' to your operator. Note: Make sure the File parameter is a standard File, as Geometry - File would set a file type filter on the chooser and you would have to set it to * to see your .txt file. geo = hou.pwd().geometry() filepath = hou.pwd().parm('file').eval() positions = hou.readFile(filepath) for line in positions.splitlines(): if line == '': continue pos = line.split() x = float(pos[0]) y = float(pos[1]) z = float(pos[2]) point = geo.createPoint() point.setPosition((x,y,z)) You could also look at writing a simple converter that could convert your .txt file into a .geo file. Edited November 15, 2008 by graham Quote Link to comment Share on other sites More sharing options...
edward Posted November 15, 2008 Share Posted November 15, 2008 Rename your file so that it has a .chan as the file extension. Put down a File CHOP and reference your file. Append a Rename CHOP to this and rename the channels to "tx ty tz". Now use a Channel SOP to reference your CHOP. Here's an example file and I've locked the File CHOP so that it's all contained in one file. posFromFile.hipnc Quote Link to comment Share on other sites More sharing options...
petz Posted November 15, 2008 Share Posted November 15, 2008 (edited) another solution is to rename your .txt file to a .chan file that you can load into chops. file is attached petz seems edward was seconds faster points1.hipnc Edited November 15, 2008 by petz Quote Link to comment Share on other sites More sharing options...
Barad-Dur Posted November 15, 2008 Author Share Posted November 15, 2008 Hey all, I just wanted to say a big thank you to you guys for helping me out on this one. I just KNEW this was a simple thing for Houdini to do and you guys have pointed me into the correct direction and for that I thank you. David Quote Link to comment Share on other sites More sharing options...
smoluck Posted September 24, 2021 Share Posted September 24, 2021 On 11/16/2008 at 2:59 AM, graham said: This is something that could easily be accomplished using a simple Python Sop. Something like this should work as long as you have added a File parameter named 'file' to your operator. Note: Make sure the File parameter is a standard File, as Geometry - File would set a file type filter on the chooser and you would have to set it to * to see your .txt file. geo = hou.pwd().geometry() filepath = hou.pwd().parm('file').eval() positions = hou.readFile(filepath) for line in positions.splitlines(): if line == '': continue pos = line.split() x = float(pos[0]) y = float(pos[1]) z = float(pos[2]) point = geo.createPoint() point.setPosition((x,y,z)) You could also look at writing a simple converter that could convert your .txt file into a .geo file. Hi Graham. just wondering, Do you have code to write to disk Point cloud Data with Pos and Color attribute to txt ? 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.