Salman
Salman

Reputation: 21

How to determine output path directory for trimesh.exchange.ply.export_ply?

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

Answers (1)

Ornstein89
Ornstein89

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()

Demo

Worked fine =) I used available free scan as input file:

enter image description here

Upvotes: 0

Related Questions