From 82294d5540536f586bfd971589684d4158b7a8b6 Mon Sep 17 00:00:00 2001 From: leyghisbb Date: Fri, 11 Sep 2020 11:40:21 +0200 Subject: [PATCH 1/2] added error handling from ODA File converter and fixed issues with ezdxf and matplotlib --- .../dxfdwgimporter/dxfdwgimporter.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py b/extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py index be9d5c66..db84c10d 100644 --- a/extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py +++ b/extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py @@ -33,8 +33,8 @@ from subprocess import Popen, PIPE import shutil from shutil import which from pathlib import Path -#from mimetypes import MimeTypes -#import urllib.request as urllib +from mimetypes import MimeTypes +import urllib.request as urllib #ezdxf related imports import matplotlib.pyplot as plt @@ -226,8 +226,18 @@ class DXFDWGImport(inkex.Effect): inkex.utils.debug("ODAFileConverter failed: %d %s %s" % (proc.returncode, stdout, stderr)) if os.name != 'nt': inkex.utils.debug("If the error message above contains a warning about wrong/missing Qt version please install the required version. You can get the installer from 'https://download.qt.io/archive/qt/'. Sadly you will need to create a free account to install. After installation please configure the shell script '/usr/bin/ODAFileConverter' to add a preceding line with content similar to 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt5.14.2/5.14.2/gcc_64/lib/'.") - exit(1) - + exit(1) + # check if ODA converted successfully. This is the case if no error file was created + oda_errorfile = os.path.join(temp_output_dir, Path(inputfile).name + ".err") + if os.path.exists(oda_errorfile): + inkex.utils.debug("ODA File Converter failed to process the file. Cannot continue DXF/DWG import. The error message is:") + errormessage = open(oda_errorfile, 'r') + errorlines = errormessage.readlines() + for errorline in errorlines: + inkex.utils.debug(errorline.strip()) + errormessage.close() + exit(1) + # Do some movings/copies of skipped or processed DXF if self.options.oda_skip_dxf_to_dxf: #if true we need to move the file to simulate "processed" shutil.move(os.path.join(temp_input_dir, Path(inputfile).name), os.path.join(temp_output_dir, Path(inputfile).name)) From 14c8047e8c6393429a7d3eebfe71e5da90053473 Mon Sep 17 00:00:00 2001 From: leyghisbb Date: Fri, 11 Sep 2020 11:55:25 +0200 Subject: [PATCH 2/2] Cleaned import name --- extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py b/extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py index db84c10d..65dfc858 100644 --- a/extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py +++ b/extensions/fablabchemnitz/dxfdwgimporter/dxfdwgimporter.py @@ -349,7 +349,7 @@ class DXFDWGImport(inkex.Effect): p = etree.XMLParser(huge_tree=True) doc = etree.parse(stream, parser=etree.XMLParser(huge_tree=True)).getroot() stream.close() - doc.set('id', self.svg.get_unique_id('dxf_dwg_import')) + doc.set('id', self.svg.get_unique_id("dxf_dwg_import-" + self.options.dxf_to_svg_parser + "-")) self.document.getroot().append(doc) #get children of the doc and move them one group above - we don't do this for bjnortier tool because this has different structure which we don't want to disturb