diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools.py b/extensions/fablabchemnitz/vpypetools/vpypetools.py index 55c951b2..eabd5f7c 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools.py +++ b/extensions/fablabchemnitz/vpypetools/vpypetools.py @@ -30,7 +30,7 @@ Extension for InkScape 1.X Author: Mario Voigt / FabLab Chemnitz Mail: mario.voigt@stadtfabrikanten.org Date: 02.04.2021 -Last patch: 06.04.2021 +Last patch: 08.04.2021 License: GNU GPL v3 This piece of spaghetti-code, called "vpypetools", is a wrapper to pass (pipe) line elements from InkScape selection (or complete canvas) to vpype. @@ -67,10 +67,6 @@ class vpypetools (inkex.EffectExtension): self.arg_parser.add_argument("--linemerge_tolerance", type=float, default=0.500, help="Maximum distance between two line endings that should be merged (default 0.500 mm)") self.arg_parser.add_argument("--linemerge_no_flip", type=inkex.Boolean, default=False, help="Disable reversing stroke direction for merging") - # Line Simplification - self.arg_parser.add_argument("--linesimplify", type=inkex.Boolean, default=False) - self.arg_parser.add_argument("--linesimplify_tolerance", type=float, default=0.050, help="The resulting geometries' points will be at a maximum distance from the original controlled by the (default 0.05 mm)") - # Trimming self.arg_parser.add_argument("--trim", type=inkex.Boolean, default=False) self.arg_parser.add_argument("--trim_x_margin", type=float, default=0.000, help="trim margin - x direction (mm)") # keep default at 0.000 to keep clean bbox @@ -120,13 +116,15 @@ 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("--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") self.arg_parser.add_argument("--output_show", type=inkex.Boolean, default=False, help="This will open a new matplotlib window showing modified SVG data") self.arg_parser.add_argument("--output_stats", type=inkex.Boolean, default=False, help="Show output statistics before/after conversion") self.arg_parser.add_argument("--output_trajectories", type=inkex.Boolean, default=False, help="Add paths for the travel trajectories") - self.arg_parser.add_argument("--keep_selection", type=inkex.Boolean, default=False, help="If false, selected paths will be removed") + self.arg_parser.add_argument("--keep_objects", type=inkex.Boolean, default=False, help="If false, selected paths will be removed") self.arg_parser.add_argument("--strokes_to_paths", type=inkex.Boolean, default=True, help="Recommended option. Performs 'Path' > 'Stroke to Path' (CTRL + ALT + C) to convert vpype converted lines back to regular path objects") - self.arg_parser.add_argument("--use_style_of_first_element", type=inkex.Boolean, default=True, help="If enabled the first element in selection is scanned and we apply it's style to all imported vpype lines") + self.arg_parser.add_argument("--use_style_of_first_element", type=inkex.Boolean, default=True, help="If enabled the first element in selection is scanned and we apply it's style to all imported vpype lines (but not for trajectories). Does not work for 'Multilayer/document'") self.arg_parser.add_argument("--lines_stroke_width", type=float, default=1.0, help="Stroke width of tooling lines (px). Gets overwritten if 'Use style of first selected element' is enabled") self.arg_parser.add_argument("--trajectories_stroke_width", type=float, default=1.0, help="Stroke width of trajectory lines (px). Gets overwritten if 'Use style of first selected element' is enabled") @@ -213,8 +211,7 @@ class vpypetools (inkex.EffectExtension): doc.add(lc, layer_id=None) # we add the lineCollection (converted selection) to the vpype document elif self.options.input_handling == "layers": - doc = vpype.read_multilayer_svg(self.options.input_file, quantization = self.options.flatness, crop = False, simplify = False, parallel = False, \ - default_width = self.document.getroot().get('width'), default_height = self.document.getroot().get('height')) + doc = vpype.read_multilayer_svg(self.options.input_file, quantization = self.options.flatness, crop = False, simplify = self.options.simplify, parallel = self.options.parallel, default_width = self.document.getroot().get('width'), default_height = self.document.getroot().get('height')) for node in self.document.getroot().xpath("//svg:g", namespaces=inkex.NSS): #all groups/layers nodesToWork.append(node) @@ -238,10 +235,6 @@ class vpypetools (inkex.EffectExtension): if self.options.linemerge_no_flip is True: command += " --no-flip" - # Line Simplification - if self.options.linesimplify is True: - command = "linesimplify --tolerance " + str(self.options.linesimplify_tolerance) - # Trimming if self.options.trim is True: command = "trim " + str(self.options.trim_x_margin) + " " + str(self.options.trim_y_margin) @@ -411,7 +404,7 @@ class vpypetools (inkex.EffectExtension): os.remove(output_file) # Remove selection objects to do a real replace with new objects from vpype document - if self.options.keep_selection is False: + if self.options.keep_objects is False: for node in nodesToWork: node.getparent().remove(node) diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx index 504ccf65..335b4697 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_filter.inx @@ -2,37 +2,54 @@ Filter fablabchemnitz.de.vpype_filter - - - true - 0.050 - false - false - false - 0.000 - false - 0.000 - - - - - + + + + true + 0.050 + false + false + false + 0.000 + false + 0.000 + + + + false + + + + + + + true + 0.100 + false + false + + + false + false + + + false + false + true + true + 1.000 + 1.000 + + + + + + + + + + - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - - diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_freemode.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_freemode.inx index 57f45ce2..faa51475 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_freemode.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_freemode.inx @@ -20,18 +20,27 @@ false + + false + + - true - 0.100 - false - false - false + true + 0.100 + false + false + + + false + false + + false - false - true + false + true true 1.000 1.000 diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_linemerge.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_linemerge.inx index 5c16670b..aee61b6c 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_linemerge.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_linemerge.inx @@ -2,32 +2,49 @@ Line Merging fablabchemnitz.de.vpype_linemerging - - - true - 0.500 - false - - - - - + + + + true + 0.500 + false + + + + false + + + + + + + true + 0.100 + false + false + + + false + false + + + false + false + true + true + 1.000 + 1.000 + + + + + + + + + + - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - - diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_linesimplify.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_linesimplify.inx deleted file mode 100644 index 3ec75e90..00000000 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_linesimplify.inx +++ /dev/null @@ -1,40 +0,0 @@ - - - Line Simplification - fablabchemnitz.de.vpype_linesimplification - - - true - 0.050 - - - - - - - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - - - - - - - - - - - \ No newline at end of file diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_linesort.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_linesort.inx index bbf91434..449509c4 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_linesort.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_linesort.inx @@ -2,31 +2,48 @@ Line Sorting fablabchemnitz.de.vpype_linesorting - - - true - false - - - - - + + + + true + false + + + + false + + + + + + + true + 0.100 + false + false + + + false + false + + + false + false + true + true + 1.000 + 1.000 + + + + + + + + + + - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - - diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_multipass.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_multipass.inx index 8d7242cf..843abb4f 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_multipass.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_multipass.inx @@ -2,31 +2,48 @@ Multipass fablabchemnitz.de.vpype_multipass - - - true - 2 - - - - - + + + + true + 2 + + + + false + + + + + + + true + 0.100 + false + false + + + false + false + + + false + false + true + true + 1.000 + 1.000 + + + + + + + + + + - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - - diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx index d0cfd0d8..4abd45d7 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_occult.inx @@ -2,31 +2,48 @@ Occult Plugin (HLR) fablabchemnitz.de.vpype_plugin_occult - - - true - 0.01 - - - - - + + + + true + 0.01 + + + + false + + + + + + + true + 0.100 + false + false + + + false + false + + + false + false + true + true + 1.000 + 1.000 + + + + + + + + + + - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - - diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_relooping.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_relooping.inx index 1859b448..2f0cc957 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_relooping.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_relooping.inx @@ -2,31 +2,48 @@ Relooping fablabchemnitz.de.vpype_relooping - - - true - 0.500 - - - - - + + + + true + 0.500 + + + + false + + + + + + + true + 0.100 + false + false + + + false + false + + + false + false + true + true + 1.000 + 1.000 + + + + + + + + + + - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - - diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_splitall.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_splitall.inx index b3d1c359..31d7c7a3 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_splitall.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_splitall.inx @@ -2,30 +2,47 @@ Split All (Break Paths) fablabchemnitz.de.vpype_splitall - - - true - - - - - + + + + true + + + + false + + + + + + + true + 0.100 + false + false + + + false + false + + + false + false + true + true + 1.000 + 1.000 + + + + + + + + + + - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - - diff --git a/extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx b/extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx index 0a7f968b..ccf452cb 100644 --- a/extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx +++ b/extensions/fablabchemnitz/vpypetools/vpypetools_trim.inx @@ -2,32 +2,49 @@ Trimming fablabchemnitz.de.vpype_trimming - - - true - 0.000 - 0.000 - - - - - + + + + true + 0.000 + 0.000 + + + + false + + + + + + + true + 0.100 + false + false + + + false + false + + + false + false + true + true + 1.000 + 1.000 + + + + + + + + + + - true - 0.100 - false - false - false - false - false - true - true - 1.000 - 1.000 - - - -