summaryrefslogtreecommitdiff
path: root/lib/extensions/cut_satin.py
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-09-29 14:00:36 -0600
committerGitHub <noreply@github.com>2018-09-29 14:00:36 -0600
commit8830eb7d40befa78c24de84694c69ab958384cac (patch)
treeeff5809a68c0c37375a5e31be8ba57763938b2dd /lib/extensions/cut_satin.py
parent5139c13fd7f43bb4d829e3c8225c51268e4d27d1 (diff)
new extension: split satin (#315)
This branch adds a new command to split a satin column at a specified point. The split happens at a stitch boundary to ensure that the two resulting satins sew just like the original. All parameters set on the original satin remain set on the two new satins, and all rungs are retained. If one of the satins would have no rungs left, a new rung is added. How to use: 1. Select a satin column (simple satin doesn't work) 2. Attach the "Satin split point" command using the "Attach commands to selected objects" extension. 3. Move the symbol (or just the connector line's endpoint) to point to the exact spot you want the satin to be split at. 4. Select the satin column again. 5. Run "Split Satin Column". 6. The split point command and connector line disappear, and nothing else appears to have happened. Select your satin and you'll see that it's been split. This extension is a by-product of my initial work on #214. Ink/Stitch will need the ability to split a satin at an arbitrary point, and I figured, why not go ahead and release that functionality as an extension while I'm at it? :)
Diffstat (limited to 'lib/extensions/cut_satin.py')
-rw-r--r--lib/extensions/cut_satin.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/extensions/cut_satin.py b/lib/extensions/cut_satin.py
new file mode 100644
index 00000000..0bef794e
--- /dev/null
+++ b/lib/extensions/cut_satin.py
@@ -0,0 +1,37 @@
+import inkex
+
+from .base import InkstitchExtension
+from ..i18n import _
+from ..elements import SatinColumn
+
+
+class CutSatin(InkstitchExtension):
+ def effect(self):
+ if not self.get_elements():
+ return
+
+ if not self.selected:
+ inkex.errormsg(_("Please select one or more satin columns to cut."))
+ return
+
+ for satin in self.elements:
+ if isinstance(satin, SatinColumn):
+ command = satin.get_command("satin_cut_point")
+
+ if command is None:
+ # L10N will have the satin's id prepended, like this:
+ # path12345: error: this satin column does not ...
+ satin.fatal(_('this satin column does not have a "satin column cut point" command attached to it. '
+ 'Please use the "Attach commands" extension and attach the "Satin Column cut point" command first.'))
+
+ split_point = command.target_point
+ command.use.getparent().remove(command.use)
+ command.connector.getparent().remove(command.connector)
+
+ new_satins = satin.split(split_point)
+ parent = satin.node.getparent()
+ index = parent.index(satin.node)
+ parent.remove(satin.node)
+ for new_satin in new_satins:
+ parent.insert(index, new_satin.node)
+ index += 1