Background, my company is very heavily reliant on importing dwg’s into their sheet sets (boo!!). We constantly have to (1)open the same file (2)make small updates (3) reimport. It would be nice if I could just keep a path to the dwg as a project param and press a button to open when needed (or script).
By changing the subprocess command to automatically use the current
program associated with the filetype, you don’t need to hard-code the current
version of AutoCAD (which may change in the future or may be different on
other user’s systems):
The Python command would work, yes—I think you have to change the “Element.Category” node to “Element.Name” to get the filename from a PDF or image.
I did run into a bug which I haven’t been able to fix—if the filename contains spaces, it won’t pass the correct filename. In Windows, the command would be start "" "filename with spaces.dwg" but the Python command doesn’t seem to be able to pass double quotes correctly (I tried the standard escape character, using single outer quotes, and using chr(34)—none seem to work).