How do I open a DWG file extension with Python?

Ballon picture Ballon · Apr 14, 2010 · Viewed 23.1k times · Source

I have a file with extension .dwg (AutoCAD), and I want to call that file from a Python console and present it on the web. Is there a module for the .dwg extension or some other solution?

Answer

ChristopheD picture ChristopheD · Apr 14, 2010

The best format for displaying these online would (imo) definitely be SVG. Recent browsers support SVG rendering natively; older ones (think IE6) may require an SVG plugin

So your best bet is probably using a command line convert tool like cad2svg (this is a free linux command line tool) which converts the DWG files to SVG. You can easily do this that from your Python program (using subprocess).