Export an object as a dxf file with RhinoScript

Hello I would like to be able to automatically save each object of my rhino model in a different dxf file. I know it can be done with a rhino script, but I don’t know what code to use to export objects to dxf. Could someone help me?

Here is my current version for reference…

BatchExportDXFByObj.py (1.4 KB)

Thanks for this script, Mitch. It works fine for *.ply too.

I added the object name to the file name.

    for i,obj in enumerate(sel_objs):
        name = rs.ObjectName(obj)
        e_file_name = '"{}-{}.{}" '.format(filename[:-4],name,ft.lower())
        #runs the export using the file name/path and your settings
        rs.Command("-_Export "+e_file_name+" _Enter", False)