Import and export ply file with the texture

I tried to write my first python script for blender, it does a very simple thing, imports ply file and exports it back:

bpy.ops.import_mesh.ply(filepath=inputFilename)

bpy.ops.export_mesh.ply(
check_existing=False,
filepath=outputFilename,
use_normals=False,
use_colors=False,
)

There are several issues:

  • in the original ply I had a texture and some texture coordinates: “element face 107920 property list uchar int vertex_indices property list uchar float texcoord” - it seems that information about texture and textcoords is completely ignored during import. How can I import all data from ply file including texture info? Is there a custom script for this task or I have to write it myself? I cannot believe that nobody faced the same problem.
  • in the original ply file the number of vertices is 53940 while in exported it is 129255! However the number of faces is the same in both cases. Where did blender get those extra vertices, how to get rid of them?

is texture info in ply format a standard? It might be not…

hard to tell where these verts come from without the ply file for testing, could be related to verts <-> loops (vertices are shared in blender).

My current solution is following: convert mesh to .obj format using meshlabserver (meshlabserver -i my.ply -o my.obj -om wt), then import it to blender using bpy.ops.import_scene.obj, then export with bpy.ops.export_scene.obj, then convert back to ply with meshlabserver. Seems to work this way :slight_smile:

1 Like