From f190593dfb4e0286f23efbec733ebf029bbca8f8 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sat, 8 Aug 2020 23:01:01 +0200 Subject: [PATCH] Added mutual cut line --- extensions/fablabchemnitz_distortion.inx | 17 ++++ .../fablabchemnitz_encoder_disk_generator.inx | 50 ++++++++++ extensions/fablabchemnitz_lowpoly.inx | 16 ++++ extensions/fablabchemnitz_mutual_cut_line.inx | 14 +++ extensions/fablabchemnitz_mutual_cut_line.py | 94 +++++++++++++++++++ ...blabchemnitz_origami_patterns_kresling.inx | 92 ++++++++++++++++++ ...bchemnitz_origami_patterns_pleat_hypar.inx | 78 +++++++++++++++ ...blabchemnitz_origami_patterns_template.inx | 90 ++++++++++++++++++ ...labchemnitz_origami_patterns_waterbomb.inx | 73 ++++++++++++++ extensions/fablabchemnitz_shelves.inx | 37 ++++++++ extensions/fablabchemnitz_tool_covers.inx | 55 +++++++++++ 11 files changed, 616 insertions(+) create mode 100644 extensions/fablabchemnitz_distortion.inx create mode 100644 extensions/fablabchemnitz_encoder_disk_generator.inx create mode 100644 extensions/fablabchemnitz_lowpoly.inx create mode 100644 extensions/fablabchemnitz_mutual_cut_line.inx create mode 100644 extensions/fablabchemnitz_mutual_cut_line.py create mode 100644 extensions/fablabchemnitz_origami_patterns_kresling.inx create mode 100644 extensions/fablabchemnitz_origami_patterns_pleat_hypar.inx create mode 100644 extensions/fablabchemnitz_origami_patterns_template.inx create mode 100644 extensions/fablabchemnitz_origami_patterns_waterbomb.inx create mode 100644 extensions/fablabchemnitz_shelves.inx create mode 100644 extensions/fablabchemnitz_tool_covers.inx diff --git a/extensions/fablabchemnitz_distortion.inx b/extensions/fablabchemnitz_distortion.inx new file mode 100644 index 00000000..cf920c89 --- /dev/null +++ b/extensions/fablabchemnitz_distortion.inx @@ -0,0 +1,17 @@ + + + Barrel Distortion + fablabchemnitz.de.distorsion + -1.0 + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_encoder_disk_generator.inx b/extensions/fablabchemnitz_encoder_disk_generator.inx new file mode 100644 index 00000000..d1b4b9ea --- /dev/null +++ b/extensions/fablabchemnitz_encoder_disk_generator.inx @@ -0,0 +1,50 @@ + + + Encoder Disk Generator + fablabchemnitz.de.encoder_disk_generator + + + 0.0 + 0.0 + 1 + 0.0 + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 1 + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 1 + 1 + 0.0 + 0.0 + + + 30.0 + 5.0 + 010011110111000010001101 + 25.0 + 10.0 + + + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_lowpoly.inx b/extensions/fablabchemnitz_lowpoly.inx new file mode 100644 index 00000000..e5715c93 --- /dev/null +++ b/extensions/fablabchemnitz_lowpoly.inx @@ -0,0 +1,16 @@ + + + Low Poly + fablabchemnitz.de.low_poly + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_mutual_cut_line.inx b/extensions/fablabchemnitz_mutual_cut_line.inx new file mode 100644 index 00000000..c5c508d9 --- /dev/null +++ b/extensions/fablabchemnitz_mutual_cut_line.inx @@ -0,0 +1,14 @@ + + + Mutual Cut Line + fablabchemnitz.de.mutual_cut_line + + path + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_mutual_cut_line.py b/extensions/fablabchemnitz_mutual_cut_line.py new file mode 100644 index 00000000..b8f5c6e7 --- /dev/null +++ b/extensions/fablabchemnitz_mutual_cut_line.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +''' +Mutual Cut Line +This Inkscape extension will take 2 selected line and cut them both +at their intersection point. +Only the first segment of a multi-segment line will be used. +''' +import inkex +from inkex.paths import Path +import simplepath +from math import * +from lxml import etree + +def error(message): + inkex.errormsg(message) + exit() + +class MultiCutEffect(inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + + def effect(self): + if len(self.svg.selected.items()) != 2: + error('Please select 2 lines before running this effect.') + + line = [] + numPaths = 0 + for id, path in self.svg.selected.items(): + if path.tag == inkex.addNS('path','svg'): + numPaths += 1 + style = path.get('style') + np = [style] + p = Path(path.get('d')).to_arrays() + for sp in p: + np.append([sp[1][0], sp[1][1]]) + line.append(np) + path.getparent().remove(path) #after cutting we remove the original lines + + if numPaths != 2: + error('Please select 2 lines before running this effect.') + + # Extract style and points for the first 2 line segments. + astyle = line[0][0] + bstyle = line[1][0] + a1x = line[0][1][0] + a1y = line[0][1][1] + a2x = line[0][2][0] + a2y = line[0][2][1] + b1x = line[1][1][0] + b1y = line[1][1][1] + b2x = line[1][2][0] + b2y = line[1][2][1] + + # Calculate intersection point. + adx = a1x - a2x + ady = a1y - a2y + bdx = b1x - b2x + bdy = b1y - b2y + + denom = adx * bdy - ady * bdx + numa = (a1x * a2y - a1y * a2x) + numb = (b1x * b2y - b1y * b2x) + x_num = numa * bdx - numb * adx + y_num = numa * bdy - numb * ady + + if denom == 0: + error('Lines don\'t intersect in a single point.') + x = x_num / denom + y = y_num / denom + + # TODO: Verify that the 2 segments intersect. + # Current code will connect outside the line segments. + + # Create 4 line segments from the intersection point. + svg_path = inkex.addNS('path','svg') + sega1 = etree.SubElement(self.svg.get_current_layer(), svg_path) + sega1.set('d', 'M '+str(x)+','+str(y)+' L '+str(a1x)+','+str(a1y)) + sega1.set('style', astyle) + + sega2 = etree.SubElement(self.svg.get_current_layer(), svg_path) + sega2.set('d', 'M '+str(x)+','+str(y)+' L '+str(a2x)+','+str(a2y)) + sega2.set('style', astyle) + + segb1 = etree.SubElement(self.svg.get_current_layer(), svg_path) + segb1.set('d', 'M '+str(x)+','+str(y)+' L '+str(b1x)+','+str(b1y)) + segb1.set('style', bstyle) + + segb2 = etree.SubElement(self.svg.get_current_layer(), svg_path) + segb2.set('d', 'M '+str(x)+','+str(y)+' L '+str(b2x)+','+str(b2y)) + segb2.set('style', bstyle) + +if __name__ == '__main__': + MultiCutEffect().run() \ No newline at end of file diff --git a/extensions/fablabchemnitz_origami_patterns_kresling.inx b/extensions/fablabchemnitz_origami_patterns_kresling.inx new file mode 100644 index 00000000..e5cad294 --- /dev/null +++ b/extensions/fablabchemnitz_origami_patterns_kresling.inx @@ -0,0 +1,92 @@ + + + Origami Pattern - Kresling tower + fablabchemnitz.de.origami_patterns.kresling_full + + + + + + + ------------------------------------------------------------ + 3 + 6 + ------------------------------------------------------------ + 10.0 + + + + + + + + + + + + + + + + + ------------------------------------------------------------ + + + + + 0.5 + 0.5 + 60.0 + + + + false + 100 + ------------------------------------------------------------ + + + true + true + 1 + 0.5 + 0.1 + 4278190335 + + + true + true + 1 + 0.25 + 0.1 + 65535 + + + true + true + false + 1 + 0.25 + 0.1 + 255 + + + false + 0.1 + 0.1 + 255 + + + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_origami_patterns_pleat_hypar.inx b/extensions/fablabchemnitz_origami_patterns_pleat_hypar.inx new file mode 100644 index 00000000..9fe8a83e --- /dev/null +++ b/extensions/fablabchemnitz_origami_patterns_pleat_hypar.inx @@ -0,0 +1,78 @@ + + + Origami Pattern - N-sided Hypar + fablabchemnitz.de.origami_patterns.pleat_hypar + + + + + + + + 100.0 + + + + + + + + 4 + 7 + false + Implements Hypar (classical hyperbolic paraboloid approximate). Classic Hypar is the easiest one to fold. However, it's not rigid foldable. More information in: Demaine, E. D., Demaine, M. L., Hart, V., Price, G. N. and Tachi, T. (2011). (Non)Existence of Pleated Folds: How Paper Folds Between Creases. Graphs and Combinatorics, 27(3), 377–397. https://doi.org/10.1007/s00373-011-1025-2 + + + + true + true + 1 + 0.5 + 0.1 + 4278190335 + + + true + true + 1 + 0.25 + 0.1 + 65535 + + + true + false + 1 + 0.25 + 0.1 + 4278255615 + + + true + true + false + 1 + 0.25 + 0.1 + 255 + + + false + 0.1 + 0.1 + 255 + + + + all + + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_origami_patterns_template.inx b/extensions/fablabchemnitz_origami_patterns_template.inx new file mode 100644 index 00000000..2b9a0825 --- /dev/null +++ b/extensions/fablabchemnitz_origami_patterns_template.inx @@ -0,0 +1,90 @@ + + + Origami Pattern - Template effect + fablabchemnitz.de.origami_patterns.template + + + + + + + 10.0 + + + + + + + 0 + The .inx file defines the bridge between Inkscape's interface and the python script. + + + + true + true + 1 + 0.5 + 0.1 + 4278190335 + + + true + true + 1 + 0.25 + 0.1 + 65535 + + + true + true + false + 1 + 0.25 + 0.1 + 255 + + + true + 0.1 + 0.1 + 255 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_origami_patterns_waterbomb.inx b/extensions/fablabchemnitz_origami_patterns_waterbomb.inx new file mode 100644 index 00000000..438adf2a --- /dev/null +++ b/extensions/fablabchemnitz_origami_patterns_waterbomb.inx @@ -0,0 +1,73 @@ + + + Origami Pattern - Waterbomb + fablabchemnitz.de.origami_patterns.magic_ball + + + + + + + + + + + false + ------------------------------ + 8 + 16 + ------------------------------ + 10.0 + + + + + + + "Waterbomb tessellation" creates a simple tessellation pattern repeating the Waterbomb base, with a half-step phase shift between each line. The Magic ball is a different design that inverts both the upper half of the first line and the bottom half of the last line. + + + + true + true + 1 + 0.5 + 0.1 + 4278190335 + + + true + true + 1 + 0.25 + 0.1 + 65535 + + + true + true + false + 1 + 0.25 + 0.1 + 255 + + + false + 0.1 + 0.1 + 255 + + + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_shelves.inx b/extensions/fablabchemnitz_shelves.inx new file mode 100644 index 00000000..128ad11c --- /dev/null +++ b/extensions/fablabchemnitz_shelves.inx @@ -0,0 +1,37 @@ + + + Parametric Shelves + fablabchemnitz.de.shelves + + <_item value="mm">mm + <_item value="cm">cm + <_item value="m">m + <_item value="km">km + <_item value="in">in + <_item value="ft">ft + <_item value="yd">yd + <_item value="pt">pt + <_item value="px">px + <_item value="pc">pc + + 1.2 + 0.3 + 0.05 + 100 + 100 + 40 + 10; 20; 35 + 0.6 + 10 + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_tool_covers.inx b/extensions/fablabchemnitz_tool_covers.inx new file mode 100644 index 00000000..4768dbb1 --- /dev/null +++ b/extensions/fablabchemnitz_tool_covers.inx @@ -0,0 +1,55 @@ + + + Tool Covers + fablabchemnitz.de.tool_covers + + + base + 20 + 40 + 40 + 20 + band + 15 + 30 + fastener + 10 + 10 + margin and needle hole + 3 + 3 + + + band + 0.7 + needle hole + 1 + 1 + 1 + true + + + PiersCover Inkscape extension + +Version 0.92 + +by Yoichi Tanibayashi + +https://ytani01.github.io/PliersCover/ + + + + + + + all + + + + + + + + \ No newline at end of file