How to open a DWG file extension using Python?

I have a file with the extension .dwg (AutoCAD) and I want to call this file from the Python console and present it on the Internet. Is there a module for extension .dwg or another solution?

+4
source share
3 answers

The best format to display these online files (imo) would definitely be SVG. Recent browsers support SVG rendering natively; older (think IE6) may require SVG plugin

So, it’s best to use a command line conversion tool like cad2svg (this is a free linux command line tool) which converts DWG files to SVG. You can easily do this from your Python program ( using subprocess ).

+4
source

Maybe something you can use in this Summer Of Code project

http://groups.fsf.org/wiki/LibreDWG/SummerOfCode

http://groups.fsf.org/wiki/LibreDWG

0
source

It is not easy to get data only from a .dwg file, but much easier from a .dxf file. So I decided to convert the .dwg file to a .dxf file and just process the .dxf file. This is not fast, but it is also an alternative, as there is no other easy way to process .dwg files.

The converter is located at https://www.opendesign.com/guestfiles/TeighaFileConverter .

My OS is CentOS 6.5 (GCC 4.4.7), so I choose Teigha File Converter for Linux 64-bit (RPM).

 #Install some qt5 lib yum install -y qt5* # If your libstdc++.so.6 has GLIBCXX>=15, you can pass the following three steps (using strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX to find) mv libstdc++.so.6.0.20 /usr/lib64/libstdc++.so.6.0.20 mv /usr/lib64/libstdc.so.6 /usr/lib64/libstdc.so.6.bk ln /usr/lib64/libstdc++.so.6.0.20 /usr/lib64/libstdc.so.6 # Install TeighaFileConverter rpm -i --nodeps TeighaFileConverter_QT5_lnxX64_4.7dll.rpm 

If you want to use the graphical interface, you need to install Qt 5, or you can just use it in the terminal or use it as shell commands in your program.

 TeighaFileConverter 'input_folder' 'output_folder' "output_version" "output_type" "recurse_folder" "audit" -platform offscreen # 'input_folder' can't be same with output_folder # For example, convert dwg to dxf TeighaFileConverter ./ ./dxf "ACAD10" "DXF" "0" "0" -platform offscreen 
0
source

Source: https://habr.com/ru/post/1306907/


All Articles