Batch Export .dwg

Hi I’m looking to export .dwg’s for every layer in a rhino file. The simple script below works but it writes over the file name with Layer, when what I want is the file to be titled by the Layer. Anything simple I can do to adjust?

Thanks in advance,

def main():
layers = rs.LayerNames()
if layers:
for layer in layers:
rs.Command(’! _-SelNone’)
rs.ObjectsByLayer(layer, True)
rs.Command(’! _-Export layer _Enter’)

if name == “main” : main()

Something like this perhaps…? (1.7 KB)

1 Like

Is there a way to export dwg by layers in solids?

This should work if the last-used DWG export scheme supports solids - i.e. 2007 Solids. Run the Rhino command Export first and make sure this scheme is set (you can cancel afterwards). Then run the batch export.

1 Like

Yes, i figured i had to change the export options before running the script. Thanks for this. I really need to get into python.