Would it be possible to specify export scheme in "Export" command?

It would be really helpful if there was an option either in the “Export” command or via any API (rhinoscript, RhinoCommon) to export selected objects to DWG via a specific Export Scheme (saved in a file). Is it possible? I couldn’t find it in the command and I couldn’t see any export command in rhinoscriptsyntax.

You need to have first created an export scheme and named it (or use one of the stock schemes). Then you can create a command line export string to run via rs.Command() or even a macro that includes the scheme.

import rhinoscriptsyntax as rs

filepath = "C:\Users\YourName\Desktop\TestFile.dxf"
comm_str = '_-Export "{}" _Scheme "2007 Natural" _Enter'.format(filepath)
rs.Command(comm_str, True)
2 Likes

-_Export C:\XXX\XXX.dwg _S 2007 Natural _EnterEnd or similar should do.

1 Like

Fantastic, thank you very much @Helvetosaur and @gankeyu. That will make things much simpler :slight_smile:

Does it work for other file formats as well? Or do you know if there is any reference for options to this command available somewhere? I couldn’t find anything in the help panel or in the first page of googling “rhino export options”.

Sorry, does it still work on Rhino 8 WIP? It errors “Unknown command: Scheme”

import rhinoscriptsyntax as rs
import os

rs.Command('-Export "C:\\Users\\<Username>\\Desktop\\test" Scheme "Default" _Enter')```

image

Nope - looks like that is pretty broken… @dale ?

For V7, you do need to specify the .dxf extension in the file name… Otherwise it doesn’t know what file format to use.

rs.Command('-Export "C:\\Users\\<Username>\\Desktop\\test.dxf" Scheme "Default" _Enter')

Personally I prefer setting up the file path separately (as in the earlier example) and using raw strings instead of escaped backslashes…

rs.Command(r'-Export "C:\Users\<username>\Desktop\test.dxf" Scheme "Default" _Enter')
1 Like

Thanks for confirming, hopefully it can be fixed soon.

Yes, the above two lines were just meant to frame the problem. In the full script I’ve added the file extension to the filename. It needs to be dwg unfortunately in autocad you can’t xref dxf files :frowning:

You are right that raw strings simplify windows file paths - I’ll try to use them more often.

import rhinoscriptsyntax as rs
import os

file_name = rs.OpenFileName()
# in case user added extension 
file_name_without_ext, file_name_with_ext = os.path.splitext(file_name)
file_name = file_name_without_ext + ".dwg"

rs.Command('-Export "{}" Scheme "Default-Copy" _Enter'.format(file_name))

DWG and DXF use the same export settings scheme, so all that is necessary in this case is to change the extension.