Jump to content

Reading Coordinate Data(XYZ) from a .txt file into Houdini.

Recommended Posts

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


Share this post

Link to post
Share on other sites

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 == '':
	pos = line.split() 

	x = float(pos[0])
	y = float(pos[1])
	z = float(pos[2])
	point = geo.createPoint()


You could also look at writing a simple converter that could convert your .txt file into a .geo file.

Edited by graham

Share this post

Link to post
Share on other sites

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.


Share this post

Link to post
Share on other sites

another solution is to rename your .txt file to a .chan file that you can load into chops.

file is attached


seems edward was seconds faster


Edited by petz

Share this post

Link to post
Share on other sites

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.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now