Reputation: 21
I am working with datasets of ply files. Eventually, I need to export the ply files in a separate directory.
Now, if I use the function trimesh.exchange.ply.export_ply, I cant seem to understand how to set the directory where to export the meshes. I have read the documentation but it didn't have any mention on how to set output path
mesh = trimesh.load("file.ply")
#print(mesh.volume)
trimesh.exchange.ply.export_ply(mesh, encoding='ascii') #How to set output directory?
Alternatively I am using mesh.export(path) which does successfully export files but with some files it gives an error when opened in meshlab or any other editor
Any suggestions on how to export as ply files?
Upvotes: 2
Views: 2830
Reputation: 676
trimesh.exchange.ply.export_ply()
produce byte array. You can write it to file you want like this:
result = trimesh.exchange.ply.export_ply(mesh, encoding='ascii')
output_file = open(your_path, "wb+")
output_file.write(result)
output_file.close()
Worked fine =) I used available free scan as input file:
Upvotes: 0