Get DocumentPath or DocumentName before file is saved?

I’m trying to reopen the same file via Python - it’s an autocad drawing that Rhino opens to use it as a base for generated geometry. However, I can’t seem to get document’s path or name without saving it somewhere first.

I hope that it’s possible, because when opening any file via Rhino it’s file name shows in Rhino window’s title, so I hope that it’s name/directory is already stored.

import rhinoscriptsyntax as rs

document_location = rs.DocumentPath() + rs.DocumentName()
rs.Command("Open No " + chr(34) + document_location + chr(34))

Hi @Daniel_Krajnik,

What you are doing is correct. Rhino doesn’t save off the name of imported, non-3dm files.

– Dale

Thanks, I understand that opening a .dwg file is the same a importing it to a default template rhino file?

I will try maybe to retrieve the imported file location name from the command history (if that’s possible).

No. When Rhino opens a non-3dm file, the contents are read into new document. They are not imported into an existing template.

– Dale

1 Like

I see, thanks again.