Skip to content

Commit 27d6d09

Browse files
authored
jump to trim: add command option: trim or jump (#4038)
1 parent 288e7a6 commit 27d6d09

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/extensions/jump_to_trim.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __init__(self, *args, **kwargs):
1717
InkstitchExtension.__init__(self, *args, **kwargs)
1818
self.arg_parser.add_argument("--tab")
1919

20+
self.arg_parser.add_argument("-c", "--command", type=str, default="trim", dest="command")
2021
self.arg_parser.add_argument("-i", "--minimum-jump-length", type=float, default=3.0, dest="min_jump")
2122
self.arg_parser.add_argument("-a", "--maximum-jump-length", type=float, default=0, dest="max_jump")
2223
self.arg_parser.add_argument("-t", "--use-command-symbols", type=Boolean, default=False, dest="use_command_symbols")
@@ -59,14 +60,20 @@ def effect(self):
5960
self._add_trim(last)
6061

6162
def _add_trim(self, element):
63+
command = "trim"
64+
param = "trim_after"
65+
if self.options.command == "stop":
66+
command = "stop"
67+
param = "stop_after"
68+
6269
# skip if the element already has a trim command in one way or the other
63-
if element.has_command("trim") or element.trim_after:
70+
if element.has_command(command) or element.trim_after:
6471
return
6572

6673
if self.options.use_command_symbols:
67-
add_commands(element, ["trim"])
74+
add_commands(element, [command])
6875
else:
69-
element.node.set('inkstitch:trim_after', True)
76+
element.node.set(f'inkstitch:{param}', True)
7077

7178
def _set_selection(self):
7279
if not self.svg.selection:

templates/jump_to_trim.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<inkscape-extension translationdomain="inkstitch" xmlns="http://www.inkscape.org/namespace/inkscape/extension">
3-
<name>Jump Stitch to Trim Command</name>
3+
<name>Jump Stitch to Trim/Stop Command</name>
44
<id>org.{{ id_inkstitch }}.jump_to_trim</id>
55
<param name="extension" type="string" gui-hidden="true">jump_to_trim</param>
66
<effect>
@@ -15,6 +15,10 @@
1515
</effect>
1616
<param name="tab" type="notebook">
1717
<page name="options" gui-text="Options">
18+
<param name="command" type="optiongroup" appearance="combo" gui-text="Command">
19+
<option value="trim">Trim</option>
20+
<option value="stop">Stop</option>
21+
</param>
1822
<param name="minimum-jump-length" type="float" precision="2" min="0" max="100"
1923
gui-text="Convert jumps not shorter than (mm)">3.0</param>
2024
<param name="maximum-jump-length" type="float" precision="2" min="0" max="10000"
@@ -25,7 +29,7 @@
2529
<param name="use-command-symbol" type="boolean" indent="1" gui-text="Use command symbol">false</param>
2630
</page>
2731
<page name="info" gui-text="Help">
28-
<label appearance="header">This extension inserts trim commands to avoid jump stitches.</label>
32+
<label appearance="header">This extension inserts trim or stop commands to avoid jump stitches.</label>
2933
<label>Get more information on our website</label>
3034
<label appearance="url">https://inkstitch.org/docs/commands/#jump-to-trim</label>
3135
</page>

0 commit comments

Comments
 (0)