Exporting OBJ in blender using script

Hello,

I need some help exporting OBJ in blender, I have it working but I want the exporter to only export the selected object in the scene. As of now it is exporting everything else.

If anyone can help, that will be huge! Thanks :smiley:

Here is my code.
def add_object(self, context):
file_export_name=‘ClipboardObj.obj’
directory = ‘C:\Users\Arvin\AppData\Roaming\DigitalFossils\NVil\Media\Clipboard’
target_file = os.path.join(directory, file_export_name)
bpy.ops.export_scene.obj(filepath=target_file)

did you try using the use_selected flag for the export operator?
https://docs.blender.org/api/current/bpy.ops.export_scene.html?highlight=use_selection#bpy.ops.export_scene.obj

Thanks! Just started learning python and blender scripting, I understand what to do :slight_smile: