From e96aab6400d01c7ff51858ee39414a6a3a0082a8 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Thu, 8 Apr 2021 14:46:30 +0200 Subject: [PATCH] Added decimal handling for paths imported in Singlelayer/paths mode --- extensions/fablabchemnitz/vpypetools/vpypetools.py | 7 ++++--- extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx | 3 ++- .../fablabchemnitz/vpypetools/vpypetools_freemode.inx | 3 ++- .../fablabchemnitz/vpypetools/vpypetools_linemerge.inx | 3 ++- .../fablabchemnitz/vpypetools/vpypetools_linesort.inx | 3 ++- .../fablabchemnitz/vpypetools/vpypetools_multipass.inx | 3 ++- extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx | 3 ++- .../fablabchemnitz/vpypetools/vpypetools_relooping.inx | 3 ++- .../fablabchemnitz/vpypetools/vpypetools_splitall.inx | 3 ++- extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx | 3 ++- 10 files changed, 22 insertions(+), 12 deletions(-) diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools.py b/extensions/fablabchemnitz/vpypetools/vpypetools.py index eabd5f7c..b3783fc3 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools.py +++ b/extensions/fablabchemnitz/vpypetools/vpypetools.py @@ -116,6 +116,7 @@ class vpypetools (inkex.EffectExtension): self.arg_parser.add_argument("--input_handling", default="paths", help="Input handling") self.arg_parser.add_argument("--flattenbezier", type=inkex.Boolean, default=False, help="Flatten bezier curves to polylines") self.arg_parser.add_argument("--flatness", type=float, default=0.1, help="Minimum flatness = 0.1. The smaller the value the more fine segments you will get (quantization).") + self.arg_parser.add_argument("--decimals", type=int, default=3, help="Accuracy for imported lines' coordinates into vpype. Does not work for 'Multilayer/document'") self.arg_parser.add_argument("--simplify", type=inkex.Boolean, default=False, help="Reduces significantly the number of segments used to approximate the curve while still guaranteeing an accurate conversion, but may increase the execution time. Does not work for 'Singlelayer/paths'") self.arg_parser.add_argument("--parallel", type=inkex.Boolean, default=False, help="Enables multiprocessing for the SVG conversion. This is recommended ONLY when using 'Simplify geometry' on large SVG files with many curved elements. Does not work for 'Singlelayer/paths'") self.arg_parser.add_argument("--apply_transformations", type=inkex.Boolean, default=False, help="Run 'Apply Transformations' extension before running vpype. Helps avoiding geometry shifting") @@ -167,7 +168,7 @@ class vpypetools (inkex.EffectExtension): points = [] for subpath in p: for csp in subpath: - points.append(Point(csp[1][0], csp[1][1])) + points.append(Point(round(csp[1][0], self.options.decimals), round(csp[1][1], self.options.decimals))) lc.append(LineString(points)) children = node.getchildren() if children is not None: @@ -254,9 +255,9 @@ class vpypetools (inkex.EffectExtension): command += " --min-length " + str(self.options.filter_min_length) if self.options.filter_max_length_enabled is True: command += " --max-length " + str(self.options.filter_max_length) - if self.options.filter_closed is True: + if self.options.filter_closed is True and self.options.filter_not_closed is False: command += " --closed" - if self.options.filter_not_closed is True: + if self.options.filter_not_closed is True and self.options.filter_closed is False: command += " --not-closed" if self.options.filter_closed is False and \ self.options.filter_not_closed is False and \ diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx index 335b4697..fd31f26b 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx @@ -24,7 +24,8 @@ true - 0.100 + 0.100 + 3 false false diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_freemode.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_freemode.inx index faa51475..6bad9648 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_freemode.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_freemode.inx @@ -29,7 +29,8 @@ true - 0.100 + 0.100 + 3 false false diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_linemerge.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_linemerge.inx index aee61b6c..7e8c5dda 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_linemerge.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_linemerge.inx @@ -19,7 +19,8 @@ true - 0.100 + 0.100 + 3 false false diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_linesort.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_linesort.inx index 449509c4..f79e2a6b 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_linesort.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_linesort.inx @@ -18,7 +18,8 @@ true - 0.100 + 0.100 + 3 false false diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_multipass.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_multipass.inx index 843abb4f..e95e28e0 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_multipass.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_multipass.inx @@ -18,7 +18,8 @@ true - 0.100 + 0.100 + 3 false false diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx index 4abd45d7..566ee306 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx @@ -18,7 +18,8 @@ true - 0.100 + 0.100 + 3 false false diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_relooping.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_relooping.inx index 2f0cc957..86f7530a 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_relooping.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_relooping.inx @@ -18,7 +18,8 @@ true - 0.100 + 0.100 + 3 false false diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_splitall.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_splitall.inx index 31d7c7a3..4f0b0ed9 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_splitall.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_splitall.inx @@ -17,7 +17,8 @@ true - 0.100 + 0.100 + 3 false false diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx index ccf452cb..8c85d2de 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx @@ -19,7 +19,8 @@ true - 0.100 + 0.100 + 3 false false