bug fixes

This commit is contained in:
Mario Voigt 2024-01-18 00:54:22 +01:00
parent 9fd854e237
commit 593538e03b
4 changed files with 23 additions and 10 deletions

View File

@ -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))

View File

@ -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();

View File

@ -19,6 +19,7 @@
<option value="R10 DXF">R10 (OpenDesign)</option>
<option value="R9 DXF">R9 (OpenDesign)</option>
</param>
<param name="qcad_join_polylines" type="bool" gui-text="Join Polylines">true</param>
<param name="qcad_tolerance" type="float" min="0.0000001" max="999999" precision="3" gui-text="Polyline tolerance" gui-description="">0.001</param>
<param name="qcad_purge_duplicates" type="bool" gui-text="Purge duplicate lines">false</param>
<param name="qcad_pro_path" type="path" mode="file" gui-text="QCAD Pro executable path" gui-description="Do not use Community Edition, as it will not work.">~/opt/qcad-3.28.2-pro-linux-x86_64/qcad</param>

View File

@ -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)