How to code a PLY export

Hello,
Im trying to write a code to export the the object that I selected to export it as the objects name and as a PLY. I am understand the basics of python coding in blender but this feels like im out of my league. I can do get it to name itself correctly I just can’t get it to export.

I found some code on Export Mesh Operators
but when I plug it in it doesn’t work. What am I doing wrong?

bpy.ops.export_mesh. ply (filepath=’’, check_existing=True, filter_glob=’.ply’*, use_ascii=False, use_selection=False, use_mesh_modifiers=True, use_normals=True, use_uv_coords=True, use_colors=True, global_scale=1.0, axis_forward=‘Y’, axis_up=‘Z’ )

I assume you activated the the ply import/export add-on, right?
What’s the error you’re getting?

I have it on in the preferences but not imported into the code do I need it?
I get an error message of invalid syntax, even though I have a file path layout.

No, you don’t need to import it explicitly in your script. You get it with
import bpy

So the line of code above is the one in your script. I thought it was copied from the docs for illustration. There’s a syntax error on the parameter of ‘filter_glob’. You put a star behind the string. According to your description of what you want to achieve, you might also just leave it away. It’s marked optional in the docs: https://docs.blender.org/api/current/bpy.ops.export_mesh.html?highlight=filter_glob
Additionally you don’t pass a concrete value to the filepath. You should name the file to be written in that parameter. You also wrote, that you want to export the selected object, but use_selection is False.
Hope that helps.

Thank you so much for the help you literally saved me!!! :pray: :pray: :pray: :pray:

1 Like