Python command line tool for .ply files

I made a small python tool in order to convert/scale/align meshes stored in ply files. It is based around plyfile, a python module that read plyfiles and convert them to numpy arrays.
It can also read/write from .mesh files, but with limited functionality.
Now it deals better with triangle meshes, but this should evolve quickly.

The program is meant to be used as a command line. The simplest use is to convert .ply to .mesh :
ply_convert.py file.ply out=file.mesh

If the input file did not have normals properly computed, this can be done on the fly. We can also scale the data by scaling factor :
ply_convert.py file.mesh -normals scale=2 out=file.ply

And there are a few more options :
ply_convert.py file.ply -center -align -normals length=7 -verbose thickness=0.15
verbose=1 out=thickened.mesh out=thickened.ply

Here we convert file.ply to thickened.mesh and thickened.ply. Before that, we center the points around 0, align them (long axis along Ox), set the length of the object on the Ox axis to 7. Here, we also add a ‘thickness’ to the surface, by adding a vector normal*thickness to each vertex.

@TODO :
– Plyfile deals gracefully with non-triangular meshes. ply_convert… who knows ?
– use align=1,2,3 to specify on which axis we want to align the points
– scale could take a vector as input as well as a scalar
– length could take a vector as input ? something like ‘7,,’ or ‘,1,’…

Code is available on github :
https://github.com/SergeDmi/Python-Tools/blob/master/ply/ply_convert.py

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *