Exemple #1
0
 def _select_doc(self):
     path, _ = qw.QFileDialog.getOpenFileName(
         self,
         caption="Select CAD Document",
         filter="CAD Documents (*.dxf *.DXF *.dwg *.DWG)",
     )
     if path:
         try:
             if os.path.splitext(path)[1].lower() == ".dwg":
                 doc = odafc.readfile(path)
                 auditor = doc.audit()
             else:
                 try:
                     doc = ezdxf.readfile(path)
                 except ezdxf.DXFError:
                     doc, auditor = recover.readfile(path)
                 else:
                     auditor = doc.audit()
             self.set_document(doc, auditor)
         except IOError as e:
             qw.QMessageBox.critical(self, "Loading Error", str(e))
         except DXFStructureError as e:
             qw.QMessageBox.critical(
                 self,
                 "DXF Structure Error",
                 f'Invalid DXF file "{path}": {str(e)}',
             )
Exemple #2
0
 def _select_doc(self):
     path, _ = qw.QFileDialog.getOpenFileName(
         self,
         caption='Select CAD Document',
         filter='DXF Documents(*.dxf);;DWG Documents(*.dwg)')
     if path:
         try:
             if os.path.splitext(path)[1].lower() == '.dwg':
                 doc = odafc.readfile(path)
             else:
                 doc = ezdxf.readfile(path)
             self.set_document(doc)
         except IOError as e:
             qw.QMessageBox.critical(self, 'Loading Error', str(e))
         except DXFStructureError as e:
             qw.QMessageBox.critical(
                 self, 'DXF Structure Error',
                 f'Invalid DXF file "{path}": {str(e)}')
Exemple #3
0
# Copyright (c) 2020-2021, Manfred Moitzi
# License: MIT License
from pathlib import Path

import ezdxf
from ezdxf.addons import odafc

FILE = "colorwh.dwg"
OUTDIR = Path("~/Desktop/outbox").expanduser()

doc = odafc.readfile(ezdxf.options.test_files_path / "AutodeskSamples" / FILE)
if doc:
    msp = doc.modelspace()
    print(f"Filename: {doc.filename}")
    print(f"DXF Version: {doc.dxfversion} - {doc.acad_release}")
    print(f"Modelspace has {len(msp)} entities.")
    doc.saveas((OUTDIR / FILE).with_suffix(".dxf"))
Exemple #4
0
# Copyright (c) 2020, Manfred Moitzi
# License: MIT License
from pathlib import Path
from ezdxf.addons import odafc

FILE = 'colorwh.dwg'
OUTDIR = Path('~/Desktop/outbox').expanduser()

doc = odafc.readfile(OUTDIR / FILE)
if doc:
    msp = doc.modelspace()
    print(f'Filename: {doc.filename}')
    print(f'DXF Version: {doc.dxfversion} - {doc.acad_release}')
    print(f'Modelspace has {len(msp)} entities.')
    doc.save()