diff --git a/extensions/fablabchemnitz/laser_check/laser_check.py b/extensions/fablabchemnitz/laser_check/laser_check.py index ef36dc9..41dcdf6 100644 --- a/extensions/fablabchemnitz/laser_check/laser_check.py +++ b/extensions/fablabchemnitz/laser_check/laser_check.py @@ -205,12 +205,8 @@ class LaserCheck(inkex.EffectExtension): #that size is actually not the stored one on file system #filesize = len(etree.tostring(self.document, pretty_print=True).decode('UTF-8')) / 1000 - filesize = 0 - if os.path.exists(self.document_path()) is False: - inkex.utils.debug("WARNING: File was not saved yet!") - else: - filesize = os.path.getsize(self.document_path()) / 1000 - inkex.utils.debug("File size: {:0.1f} KB (That might be wrong. Check first for recently saved file)".format(filesize)) + filesize = os.path.getsize(so.input_file) / 1000 + inkex.utils.debug("File size: {:0.1f} KB".format(filesize)) if filesize > so.filesize_max: inkex.utils.debug("WARNING: file size is larger than allowed: {} KB > {} KB".format(filesize, so.filesize_max)) diff --git a/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad-dxf-script.js b/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad-dxf-script.js index 31e7f6d..23ee50e 100644 --- a/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad-dxf-script.js +++ b/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad-dxf-script.js @@ -10,13 +10,15 @@ var storage = new RMemoryStorage(); var spatialIndex = new RSpatialIndexSimple(); var doc = new RDocument(storage, spatialIndex); var di = new RDocumentInterface(doc); + var tolerance = $QCAD_TOLERANCE$; +var purge_duplicates = $QCAD_PURGE_DUPLICATES$; +var join_polylines = $QCAD_JOIN_POLYLINES$; const importer = new SvgImporter(doc); di.importFile("$SVG_PATH$"); -var purge_duplicates = $QCAD_PURGE_DUPLICATES$; if (purge_duplicates === true) { Duplicates.findDuplicates(di, true, tolerance, 0.0, true); var counter = doc.countSelectedEntities(); @@ -25,8 +27,10 @@ if (purge_duplicates === true) { print("Purged duplicates: " + counter); } -di.selectAll(); +if (join_polylines === true) { + di.selectAll(); + PolylineFromSelection.autoJoinSegments(di, tolerance); +} -PolylineFromSelection.autoJoinSegments(di, tolerance); di.exportFile("$EXPORT_PATH$", "$QCAD_DXF_FORMAT$"); di.destroy(); \ No newline at end of file diff --git a/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.inx b/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.inx index 9c0220f..a291816 100644 --- a/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.inx +++ b/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.inx @@ -19,6 +19,7 @@ + true 0.001 false ~/opt/qcad-3.28.2-pro-linux-x86_64/qcad diff --git a/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.py b/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.py index b2ad26e..c7c9929 100644 --- a/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.py +++ b/extensions/fablabchemnitz/qcad_svg_to_modern_dxf/qcad_svg_to_modern_dxf.py @@ -28,6 +28,7 @@ class QCAD_SVG(inkex.OutputExtension): def add_arguments(self, pars): pars.add_argument("--tab") pars.add_argument("--qcad_dxf_format", default="dxflib", help="DXF Export Type") + pars.add_argument("--qcad_join_polylines", type=inkex.Boolean, default=True, help="Join Polylines") pars.add_argument("--qcad_tolerance", type=float, default=0.001, help="Polyline Tolerance") pars.add_argument("--qcad_purge_duplicates", type=inkex.Boolean, default=False, help="Purge duplicate lines") pars.add_argument("--qcad_pro_path", default="~/opt/qcad-3.28.2-pro-linux-x86_64/qcad", help="Location of qcad pro executable") @@ -43,18 +44,28 @@ class QCAD_SVG(inkex.OutputExtension): def effect(self): so = self.options + + if os.path.exists(so.input_file) is False: + inkex.utils.debug("WARNING: File was not saved yet! Try again after saving.") + exit(1) + qcad_pro_path = os.path.relpath(so.qcad_pro_path) tmpdir_path = os.path.dirname(so.input_file) export_path = self.document_path() qcad_script = "qcad-dxf-script.js" + if so.qcad_join_polylines is True: + qcad_join_polylines = "true" + else: + qcad_join_polylines = "false" + qcad_tolerance = "{:6.6f}".format(so.qcad_tolerance) if so.qcad_purge_duplicates is True: qcad_purge_duplicates = "true" else: qcad_purge_duplicates = "false" - qcad_tolerance = "{:6.6f}".format(so.qcad_tolerance) qcad_dxf_format = so.qcad_dxf_format if so.debug is True: + inkex.utils.debug("Input file:{}".format(so.input_file)) inkex.utils.debug("/tmp dir Path:{}".format(tmpdir_path)) inkex.utils.debug("Export Path{}".format(export_path)) inkex.utils.debug("QCAD Pro Path: {}".format(qcad_pro_path)) @@ -69,6 +80,7 @@ class QCAD_SVG(inkex.OutputExtension): shutil.copy2(qcad_script, tmpdir_path) qcad_script_tmp = os.path.join(tmpdir_path, qcad_script) self.inplace_change(qcad_script_tmp, "$SVG_PATH$", target_file) + self.inplace_change(qcad_script_tmp, "$QCAD_JOIN_POLYLINES$", qcad_join_polylines) self.inplace_change(qcad_script_tmp, "$QCAD_TOLERANCE$", qcad_tolerance) self.inplace_change(qcad_script_tmp, "$EXPORT_PATH$", export_path) self.inplace_change(qcad_script_tmp, "$QCAD_DXF_FORMAT$", qcad_dxf_format)