Point cloud import add-on

Feel free to contribute to the Python add-on and/or use it.
https://github.com/cookycat/pointcloud

The add-on allows you to define the color mode of point sets to be RGBA or BGRA without having to use a script. Additional features are the ability to offset the cloud from origin as well as scale it, and define the point size in pixels.

VC 4.2 introduced new API for point clouds, such as getters and setters for point positions and color. First version of add-on simply aims to help you avoid scripting and quickly fix color issues with the points, such as points appear blue instead of red and vice-versa.

NB! The add-on uses the import geometry command, so the file formats supported by your VC-based product will dictate what can be imported, such as XYZ, PTS and XYZRGB.

Other comments:

  • If someone already has a LAS importer, let me know, so I don’t waste my time making one or use converter like las2txt.
  • PIL and point cloud API can be used to import images as point clouds. Based on some initial tests, I would say it is better to use the Picture Frame component in the eCat right now to avoid Gaussian blur/noise when the 3D camera gets too close to the image.
1 Like

Be aware of issue regarding XYZARGB, e.g. PTS file generated from Autodesk ReCAP.

The Import Geometry command cannot distinguish the A and RGB channels, so the file would be read as XYZRGBA meaning the RGB color would be wrong. This is current status as of VC 4.3.1.

You can workaround this specifying the format used in the PTS file when creating it (if the software supports this) OR convert the PTS file data to be in XYZRGBA format.

Here is sample code of how to convert from XYZARGB to XYZRGBA

file_path = "<path to file>"
new_lines = []
with open(file_path, "r") as f:
  count = f.readline()
  new_lines.append(count)
  for line in f:
    point = line.split(" ")
    b_channel = point[-1]
    b_channel = b_channel.rstrip("\n")
    point[-1] = b_channel
    a_channel = p.pop(3)
    point.append(a_channel)
      
    #ugly but illustrates how the new line for the point is defined
    new_line = "{0} {1} {2} {3} {4} {5} {6}\n".format(p[0],p[1],p[2],p[3],p[4],p[5],p[6])
    new_lines.append(new_line)
	
file_path = "<path to new file>"    
with open(file_path, "w") as f:
  f.writelines(new_lines)

Making your add-on as demonstrated in this Academy tutorial is better at handling all use cases.

You could, however, modify the add-on in the github project to handle different formats, but this requires knowing what formats the Import Geometry command can and cannot handle properly.