Jump to content
nicholasds

Load ASCII PTX data into Houdini

Recommended Posts

Hi all.

Can anyone tell me what the best method for bringing in ASCII data into Houdini would be. I have PTX point clouds that I would like to mesh in Houdini, but I can't load them. Here's an example of the first 20 lines from one of the PTX files:

3680
2463
7115.197796 14574.203673 51.118767
0.737771 -0.675051 0
0.675051 0.737771 0
0 0 1
0.737771 -0.675051 0 0
0.675051 0.737771 0 0
0 0 1 0
7115.197796 14574.203673 51.118767 1
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0
0 0 0 0.500000 0 0 0

Thanks!

Share this post


Link to post
Share on other sites

I have never deal with PTX, but I think Python is a way to go.

If there are point coordinates in this file and you need to create the same points in Houdini, you can read them with Python, then create points (either with Python or with VEX). Should not be that hard to create a script which does this, more tricky would be to update point cloud in Houdini if PTX file was changed.

Edited by kiryha

Share this post


Link to post
Share on other sites

With a single point cloud you could only create points for lines in your file that contain exactly 7 values (standing for Px, Py, Pz, I, Cr, Cg, Cb):

import csv

node = hou.pwd()
geo = node.geometry()
path = node.evalParm('path')

geo.addAttrib(hou.attribType.Point, 'Cd', (-1.0,-1.0,-1.0))
geo.addAttrib(hou.attribType.Point, 'intensity', -1.0)

def add_point(position, color, intensity):
    pt = geo.createPoint()
    pt.setPosition(hou.Vector3(position))
    pt.setAttribValue('Cd', color)
    pt.setAttribValue('intensity', intensity)

with open(path) as f:
    reader = csv.reader(f)
    for row in reader:
        values = row[0].split()
        if len(values) == 7:
            pos = tuple([float(i) for i in values[0:3]])
            ins = float(values[3])
            clr = tuple([float(i)/255.0 for i in values[4:7]])
            add_point(pos, clr, ins)

And perhaps filter out 'missing points' by removing any point that was set to 0,0,0:

if(length(v@P) < 0.001){
    removepoint(0, @ptnum);
}

 

import_point_cloud.png

py_import_ptx_02.hiplc

  • Like 1

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

×