diff --git a/extensions/fablabchemnitz/flashburst.inx b/extensions/fablabchemnitz/flashburst.inx
new file mode 100644
index 00000000..5af9722e
--- /dev/null
+++ b/extensions/fablabchemnitz/flashburst.inx
@@ -0,0 +1,27 @@
+
+
+ Flash Burst
+ fablabchemnitz.de.flash_burst
+ 10
+ 10
+
+ 350
+ 350
+
+ 5
+ 10
+
+ 3
+ 5
+
+ all
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/extensions/fablabchemnitz/flashburst.py b/extensions/fablabchemnitz/flashburst.py
new file mode 100755
index 00000000..d5abab34
--- /dev/null
+++ b/extensions/fablabchemnitz/flashburst.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2021 Stefan Benediktsson
+#
+# GNU Affero General Public License v3.0
+# Permissions of this strongest copyleft license are
+# conditioned on making available complete source code
+# of licensed works and modifications, which include
+# larger works using a licensed work, under the same
+# license. Copyright and license notices must be preserved.
+# Contributors provide an express grant of patent rights.
+# When a modified version is used to provide a service
+# over a network, the complete source code of the modified
+# version must be made available.
+"""
+Generate a FlashBurst as SVG.
+"""
+
+import random
+from math import acos, cos, radians, sin, sqrt, tan
+
+import inkex
+
+
+def points_to_svgd(p):
+ """
+ p: list of 2 tuples (x, y coordinates)
+ """
+ f = p[0]
+ p = p[1:]
+ svgd = 'M{:.3f},{:.3f}'.format(f[0], f[1])
+ for x in p:
+ svgd += 'L{:.3f},{:.3f}'.format(x[0], x[1])
+ svgd +='Z'
+ return svgd
+
+def checkSize(a, b):
+ if a >= b:
+ return b, a
+ else:
+ return a, b
+
+class FlashBurst(inkex.GenerateExtension):
+ container_label = 'Rendered FlashBurst'
+ def add_arguments(self, pars):
+
+ pars.add_argument("--r1", type=int, default=20, help="Inner Radius min")
+ pars.add_argument("--r2", type=int, default=20, help="Inner Radius max")
+ pars.add_argument("--R1", type=int, default=350, help="Outer Radius min")
+ pars.add_argument("--R2", type=int, default=350, help="Outer Radius min")
+ pars.add_argument("--a1", type=int, default=5, help="Angle min")
+ pars.add_argument("--a2", type=int, default=7, help="Angle max")
+ pars.add_argument("--ad1", type=int, default=3, help="Angle delta min")
+ pars.add_argument("--ad2", type=int, default=2, help="Angle delta max")
+
+
+
+ def generate(self):
+ r1 = self.options.r1
+ r2 = self.options.r2
+ R1 = self.options.R1
+ R2 = self.options.R2
+ a1 = self.options.a1
+ a2 = self.options.a2
+ ad1 = self.options.ad1
+ ad2 = self.options.ad2
+
+ # generate points: list of (x, y) pairs
+
+ r1, r2 = checkSize(r1, r2)
+ R1, R2 = checkSize(R1, R2)
+ a1, a2 = checkSize(a1, a2)
+ ad1, ad2 = checkSize(ad1, ad2)
+
+ a = 0
+ oX = 0
+ oY = 0
+ style = {'stroke': '#000000', 'fill': '#000000', 'stroke-width': str(self.svg.unittouu('1px'))}
+
+ while a < 360:
+ a = a+random.randint(a1,a2)
+ dI = random.randint(r1,r2)
+ dO = random.randint(R1,R2)
+ ad = random.randint(ad1,ad2)
+
+ x0 = cos(radians(a)) * dI
+ y0 = sin(radians(a)) * dI
+
+ x10 = cos(radians(a-ad/2)) * dO
+ y10 = sin(radians(a-ad/2)) * dO
+
+ x11 = cos(radians(a+ad/2)) * dO
+ y11 = sin(radians(a+ad/2)) * dO
+
+ points = []
+ points.append((x0, y0))
+ points.append((x10,y10))
+ points.append((x11,y11))
+ path = points_to_svgd(points)
+
+ yield inkex.PathElement(style=str(inkex.Style(style)), d=str(path))
+
+if __name__ == '__main__':
+ FlashBurst().run()
+
diff --git a/extensions/fablabchemnitz/paths2openscad.inx b/extensions/fablabchemnitz/paths2openscad.inx
index 9e17736d..0a0586d8 100644
--- a/extensions/fablabchemnitz/paths2openscad.inx
+++ b/extensions/fablabchemnitz/paths2openscad.inx
@@ -26,7 +26,7 @@
0.2
0
-
+
diff --git a/extensions/fablabchemnitz/paths2openscad.py b/extensions/fablabchemnitz/paths2openscad.py
index a64baeb1..d3298366 100644
--- a/extensions/fablabchemnitz/paths2openscad.py
+++ b/extensions/fablabchemnitz/paths2openscad.py
@@ -418,31 +418,30 @@ def msg_extrude_by_hull_and_paths(id, prefix):
return msg
-class OpenSCAD(inkex.Effect):
- def __init__(self):
+class OpenSCAD(inkex.EffectExtension):
+ def add_arguments(self, pars):
inkex.localization.localize() # does not help for localizing my *.inx file
- inkex.Effect.__init__(self)
- self.arg_parser.add_argument( "--tab", default="splash", help="The active tab when Apply was pressed", )
- self.arg_parser.add_argument( "--smoothness", type=float, default=float(0.2), help="Curve smoothing (less for more)", )
- self.arg_parser.add_argument( "--chamfer", type=float, default=float(1.), help="Add a chamfer radius, displacing all object walls outwards [mm]", )
- self.arg_parser.add_argument( "--chamfer_fn", type=int, default=int(4), help="Chamfer precision ($fn when generating the minkowski sphere)", )
- self.arg_parser.add_argument( "--zsize", default="5", help="Depth (Z-size) [mm]", )
- self.arg_parser.add_argument( "--min_line_width", type=float, default=float(1), help="Line width for non closed curves [mm]", )
- self.arg_parser.add_argument( "--line_width_scale_perc", type=float, default=float(1), help="Percentage of SVG line width. Use e.g. 26.46 to compensate a px/mm confusion. Default: 100 [%]", )
- self.arg_parser.add_argument( "--line_fn", type=int, default=int(4), help="Line width precision ($fn when constructing hull)", )
- self.arg_parser.add_argument( "--force_line", type=inkex.utils.Boolean, default=False, help="Force outline mode.", )
- self.arg_parser.add_argument( "--fname", default="{NAME}.scad", help="openSCAD output file derived from the svg file name.", )
- self.arg_parser.add_argument( "--parsedesc", default="true", help="Parse zsize and other parameters from object descriptions", )
- self.arg_parser.add_argument( "--scadview", default="false", help="Open the file with openscad ( details see --scadviewcmd option )", )
- self.arg_parser.add_argument( "--scadviewcmd", default=INX_SCADVIEW, help="Command used start an openscad viewer. Use {SCAD} for the openSCAD input.", )
- self.arg_parser.add_argument( "--scad2stl", default="false", help="Also convert to STL ( details see --scad2stlcmd option )", )
- self.arg_parser.add_argument( "--scad2stlcmd", default=INX_SCAD2STL, help="Command used to convert to STL. You can use {NAME}.scad for the openSCAD file to read and "
+ pars.add_argument( "--tab", default="splash", help="The active tab when Apply was pressed", )
+ pars.add_argument( "--smoothness", type=float, default=float(0.2), help="Curve smoothing (less for more)", )
+ pars.add_argument( "--chamfer", type=float, default=float(1.), help="Add a chamfer radius, displacing all object walls outwards [mm]", )
+ pars.add_argument( "--chamfer_fn", type=int, default=int(4), help="Chamfer precision ($fn when generating the minkowski sphere)", )
+ pars.add_argument( "--zsize", default="5", help="Depth (Z-size) [mm]", )
+ pars.add_argument( "--min_line_width", type=float, default=float(1), help="Line width for non closed curves [mm]", )
+ pars.add_argument( "--line_width_scale_perc", type=float, default=float(1), help="Percentage of SVG line width. Use e.g. 26.46 to compensate a px/mm confusion. Default: 100 [%]", )
+ pars.add_argument( "--line_fn", type=int, default=int(4), help="Line width precision ($fn when constructing hull)", )
+ pars.add_argument( "--force_line", type=inkex.utils.Boolean, default=False, help="Force outline mode.", )
+ pars.add_argument( "--fname", default="{NAME}.scad", help="openSCAD output file derived from the svg file name.", )
+ pars.add_argument( "--parsedesc", default="true", help="Parse zsize and other parameters from object descriptions", )
+ pars.add_argument( "--scadview", default="false", help="Open the file with openscad ( details see --scadviewcmd option )", )
+ pars.add_argument( "--scadviewcmd", default=INX_SCADVIEW, help="Command used start an openscad viewer. Use {SCAD} for the openSCAD input.", )
+ pars.add_argument( "--scad2stl", default="false", help="Also convert to STL ( details see --scad2stlcmd option )", )
+ pars.add_argument( "--scad2stlcmd", default=INX_SCAD2STL, help="Command used to convert to STL. You can use {NAME}.scad for the openSCAD file to read and "
+ "{NAME}.stl for the STL file to write.", )
- self.arg_parser.add_argument( "--stlpost", default="false", help="Start e.g. a slicer. This implies the --scad2stl option. ( see --stlpostcmd )", )
- self.arg_parser.add_argument( "--stlpostcmd", default=INX_STL_POSTPROCESSING, help="Command used for post processing an STL file (typically a slicer). You can use {NAME}.stl for the STL file.", )
- self.arg_parser.add_argument( "--stlmodule",default="false", help="Output configured to comment out final rendering line, to create a module file for import.", )
+ pars.add_argument( "--stlpost", default="false", help="Start e.g. a slicer. This implies the --scad2stl option. ( see --stlpostcmd )", )
+ pars.add_argument( "--stlpostcmd", default=INX_STL_POSTPROCESSING, help="Command used for post processing an STL file (typically a slicer). You can use {NAME}.stl for the STL file.", )
+ pars.add_argument( "--stlmodule",default="false", help="Output configured to comment out final rendering line, to create a module file for import.", )
self.userunitsx = 1.0 # Move to pure userunits per mm for v1.0
self.userunitsy = 1.0
@@ -1396,9 +1395,9 @@ module chamfer_sphere(rad=chamfer, res=chamfer_fn)
except Exception:
tty = subprocess.PIPE
try:
- proc = subprocess.Popen(
- cmd, shell=True, stdin=tty, stdout=tty, stderr=tty
- )
+ proc = subprocess.Popen(cmd, shell=True, stdin=tty, stdout=tty, stderr=tty)
+ proc.wait()
+ tty.close()
except OSError as e:
raise OSError("%s failed: errno=%d %s" % (cmd, e.errno, e.strerror))
try:
@@ -1428,13 +1427,8 @@ module chamfer_sphere(rad=chamfer, res=chamfer_fn)
import subprocess
try:
- proc = subprocess.Popen(
- cmd,
- shell=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc.wait()
except OSError as e:
raise OSError(
"{0} failed: errno={1} {2}".format(cmd, e.errno, e.strerror)
@@ -1459,8 +1453,7 @@ module chamfer_sphere(rad=chamfer, res=chamfer_fn)
inkex.errormsg("= " * 24)
if len <= 0: # something is wrong. better stop here
self.options.stlpost = "false"
- stdout.close()
- stderr.close()
+ proc.wait()
if self.options.stlpost == "true":
cmd = self.options.stlpostcmd.format(
**{"STL": self.basename + ".stl", "NAME": self.basename}
@@ -1471,9 +1464,8 @@ module chamfer_sphere(rad=chamfer, res=chamfer_fn)
tty = subprocess.PIPE
try:
- proc = subprocess.Popen(
- cmd, shell=True, stdin=tty, stdout=tty, stderr=tty
- )
+ proc = subprocess.Popen(cmd, shell=True, stdin=tty, stdout=tty, stderr=tty)
+ proc.wait()
except OSError as e:
raise OSError("%s failed: errno=%d %s" % (cmd, e.errno, e.strerror))
@@ -1487,8 +1479,6 @@ module chamfer_sphere(rad=chamfer, res=chamfer_fn)
if stderr:
inkex.errmsg("STDERR: {}".format(stderr))
inkex.errormsg("= " * 24)
- stdout.close()
- stderr.close()
if __name__ == '__main__':
OpenSCAD().run()
\ No newline at end of file
diff --git a/extensions/fablabchemnitz/starshine.inx b/extensions/fablabchemnitz/starshine.inx
new file mode 100644
index 00000000..db0e3027
--- /dev/null
+++ b/extensions/fablabchemnitz/starshine.inx
@@ -0,0 +1,24 @@
+
+
+ Starshine
+ fablabchemnitz.de.starshine
+ 10
+ 10
+
+ 350
+ 350
+
+ 4
+ 10
+
+ all
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/extensions/fablabchemnitz/starshine.py b/extensions/fablabchemnitz/starshine.py
new file mode 100755
index 00000000..948a4dc7
--- /dev/null
+++ b/extensions/fablabchemnitz/starshine.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2021 Stefan Benediktsson
+#
+# GNU Affero General Public License v3.0
+# Permissions of this strongest copyleft license are
+# conditioned on making available complete source code
+# of licensed works and modifications, which include
+# larger works using a licensed work, under the same
+# license. Copyright and license notices must be preserved.
+# Contributors provide an express grant of patent rights.
+# When a modified version is used to provide a service
+# over a network, the complete source code of the modified
+# version must be made available.
+#
+"""
+Generate a Starshine as SVG.
+"""
+
+import random
+from math import acos, cos, radians, sin, sqrt, tan
+
+import inkex
+
+
+
+def points_to_svgd(p):
+ """
+ p: list of 2 tuples (x, y coordinates)
+ """
+ f = p[0]
+ p = p[1:]
+ svgd = 'M{:.3f},{:.3f}'.format(f[0], f[1])
+ for x in p:
+ svgd += 'L{:.3f},{:.3f}'.format(x[0], x[1])
+ svgd +='Z'
+ return svgd
+
+def checkSize(a, b):
+ if a >= b:
+ return b, a
+ else:
+ return a, b
+
+class Starshine(inkex.GenerateExtension):
+ container_label = 'Rendered Starshine'
+ def add_arguments(self, pars):
+
+ pars.add_argument("--r1", type=int, default=20, help="Inner Radius min")
+ pars.add_argument("--r2", type=int, default=20, help="Inner Radius max")
+ pars.add_argument("--R1", type=int, default=350, help="Outer Radius min")
+ pars.add_argument("--R2", type=int, default=350, help="Outer Radius min")
+ pars.add_argument("--a1", type=int, default=5, help="Angle min")
+ pars.add_argument("--a2", type=int, default=7, help="Angle max")
+
+
+
+ def generate(self):
+ r1 = self.options.r1
+ r2 = self.options.r2
+ R1 = self.options.R1
+ R2 = self.options.R2
+ a1 = self.options.a1
+ a2 = self.options.a2
+
+
+ # generate points: list of (x, y) pairs
+
+ r1, r2 = checkSize(r1, r2)
+ R1, R2 = checkSize(R1, R2)
+ a1, a2 = checkSize(a1, a2)
+ a = 0
+
+ style = {'stroke': '#000000', 'fill': '#000000', 'stroke-width': str(self.svg.unittouu('1px'))}
+
+ points = []
+
+ while a < 360:
+ dI = random.randint(r1,r2)
+ dO = random.randint(R1,R2)
+ ad = random.randint(a1,a2)
+
+ x00 = cos(radians(a)) * dI
+ y00 = sin(radians(a)) * dI
+
+ x10 = cos(radians(a+ad/2)) * dO
+ y10 = sin(radians(a+ad/2)) * dO
+
+ x01 = cos(radians(a+ad)) * dI
+ y01 = sin(radians(a+ad)) * dI
+
+ points.append((x00, y00))
+ points.append((x10, y10))
+ points.append((x01, y01))
+
+ a = a+ad
+
+ path = points_to_svgd(points)
+
+ yield inkex.PathElement(style=str(inkex.Style(style)), d=str(path))
+
+
+if __name__ == '__main__':
+ Starshine().run()
+