fixed inkpacking to be compatible for lasercutters

This commit is contained in:
Mario Voigt 2021-05-14 02:51:13 +02:00
parent 3415119ab0
commit 624189b2fa
1 changed files with 464 additions and 436 deletions

View File

@ -110,7 +110,9 @@ class inkpacking(inkex.EffectExtension):
box_id = self.svg.get_unique_id('box')
self.box = g = etree.SubElement(self.svg.get_current_layer(), 'g', {'id':box_id})
line_style = str(inkex.Style(({ 'stroke': '#000000', 'fill': 'none', 'stroke-width':'0.1' })))
cut_line_style = str(inkex.Style(({ 'stroke': '#000000', 'fill': 'none', 'stroke-width':'0.3px' })))
engrave_line_style = str(inkex.Style(({ 'stroke': '#ff0000', 'fill': 'none', 'stroke-width':'0.3px' })))
gflapoffy = (gflapsize / sin( (gflapangle / 360) * 6.28 )) * sin( ((90 - gflapangle) / 360 ) * 6.28)
# Side Glueflap
@ -120,8 +122,7 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [gflapsize * -1, gflapoffy]],
[ 'L', [gflapsize * -1, boxH - gflapoffy]],
[ 'L', [0, boxH]],
[ 'M', [ 0 , 0 ] ],
[ 'Z', [] ]
[ 'M', [0, 0]]
]
if gfmirror:
@ -130,33 +131,48 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW+boxD+boxW+boxD - thck + gflapsize, gflapoffy]],
[ 'L', [boxW+boxD+boxW+boxD - thck + gflapsize, boxH - gflapoffy]],
[ 'L', [boxW+boxD+boxW+boxD - thck, boxH]],
[ 'M', [ boxW+boxD+boxW+boxD - thck, 0 ] ],
[ 'Z', [] ]
[ 'M', [boxW+boxD+boxW+boxD - thck, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-sideglueflap', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-sideglueflap', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# MainBody
line_path = [
[ 'M', [0, 0]],
[ 'L', [ 0 , boxH ] ],
[ 'L', [0, boxH]]
]
if gfmirror:
style = cut_line_style
else:
style = engrave_line_style
line_atts = { 'style':style, 'id':box_id+'-body-left', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_path = [
[ 'M', [boxW, 0]],
[ 'L', [boxW, boxH]],
[ 'M', [boxW + boxD, 0]],
[ 'L', [boxW + boxD, boxH]],
[ 'M', [boxW + boxD + boxW, 0]],
[ 'L', [ boxW + boxD + boxW, boxH ] ],
[ 'L', [boxW + boxD + boxW, boxH]]
]
line_atts = { 'style':engrave_line_style, 'id':box_id+'-body-mid', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if gfmirror:
style = engrave_line_style
else:
style = cut_line_style
line_path = [
[ 'M', [boxW + boxD + boxW + boxD - thck, 0]],
[ 'L', [boxW + boxD + boxW + boxD - thck, boxH]],
[ 'M', [ 0, 0 ] ],
[ 'Z', [] ]
]
line_atts = { 'style':line_style, 'id':box_id+'-body', 'd':str(Path(line_path)) }
line_atts = { 'style':style, 'id':box_id+'-body-left', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# No Top Option
@ -167,8 +183,7 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW, 0]],
[ 'L', [boxW + boxD, 0]],
[ 'L', [boxW + boxD + boxW, 0]],
[ 'L', [ boxW + boxD + boxW + boxD - thck, 0 ] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW + boxD - thck, 0]]
]
if fingergrepa and not fingergrepb:
line_path = [
@ -180,9 +195,7 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW + boxD + boxW / 2 - fingergrepr, 0]],
[ 'A', [fingergrepr, fingergrepr, 0, 1, 0, boxW + boxD + boxW - boxW / 2 + fingergrepr, 0]],
[ 'L', [boxW + boxD + boxW, 0]],
[ 'L', [ boxW + boxD + boxW + boxD - thck , 0 ] ],
[ 'M', [ 0 , 0] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW + boxD - thck, 0]]
]
if fingergrepa and fingergrepb:
line_path = [
@ -198,9 +211,7 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW + boxD + boxW, 0]],
[ 'L', [boxW + boxD + boxW + boxD - thck - ( (boxD - thck) / 2 ) - fingergrepr, 0]],
[ 'A', [fingergrepr, fingergrepr, 0, 1, 0, boxW + boxD + boxW - thck + boxD - ( ( boxD - thck ) / 2 ) + fingergrepr , 0]],
[ 'L', [ boxW + boxD + boxW + boxD - thck , 0 ] ],
[ 'M', [ 0 , 0] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW + boxD - thck, 0]]
]
if not fingergrepa and fingergrepb:
@ -213,13 +224,11 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW + boxD + boxW, 0]],
[ 'L', [boxW + boxD + boxW + boxD - thck - ( (boxD - thck) / 2 ) - fingergrepr, 0]],
[ 'A', [fingergrepr, fingergrepr, 0, 1, 0, boxW + boxD + boxW - thck + boxD - ( ( boxD - thck ) / 2 ) + fingergrepr , 0]],
[ 'L', [ boxW + boxD + boxW + boxD - thck , 0 ] ],
[ 'M', [ 0 , 0] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW + boxD - thck, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-topdraw', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-topdraw', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# No Bottom Option
@ -230,8 +239,7 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW, boxH]],
[ 'L', [boxW + boxD, boxH]],
[ 'L', [boxW + boxD + boxW, boxH]],
[ 'L', [ boxW + boxD + boxW + boxD - thck, boxH ] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW + boxD - thck, boxH]]
]
if fingergrepa and not fingergrepb:
line_path = [
@ -244,8 +252,7 @@ class inkpacking(inkex.EffectExtension):
[ 'A', [fingergrepr, fingergrepr, 0, 1, 1, boxW + boxD + boxW - boxW / 2 + fingergrepr, boxH]],
[ 'L', [boxW + boxD + boxW, boxH]],
[ 'L', [boxW + boxD + boxW + boxD - thck, boxH]],
[ 'M', [ 0 , boxH ] ],
[ 'Z', [] ]
[ 'M', [0, boxH]]
]
if fingergrepa and fingergrepb:
line_path = [
@ -262,8 +269,7 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW + boxD + boxW + boxD - thck - ( (boxD - thck) / 2 ) - fingergrepr, boxH]],
[ 'A', [fingergrepr, fingergrepr, 0, 1, 1, boxW + boxD + boxW - thck + boxD - ( ( boxD - thck ) / 2 ) + fingergrepr , boxH]],
[ 'L', [boxW + boxD + boxW + boxD - thck, boxH]],
[ 'M', [ 0 , boxH ] ],
[ 'Z', [] ]
[ 'M', [0, boxH]]
]
if not fingergrepa and fingergrepb:
@ -277,11 +283,10 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW + boxD + boxW + boxD - thck - ( (boxD - thck) / 2 ) - fingergrepr, boxH]],
[ 'A', [fingergrepr, fingergrepr, 0, 1, 1, boxW + boxD + boxW - thck + boxD - ( ( boxD - thck ) / 2 ) + fingergrepr , boxH]],
[ 'L', [boxW + boxD + boxW + boxD - thck, boxH]],
[ 'M', [ 0 , boxH ] ],
[ 'Z', [] ]
[ 'M', [0, boxH]]
]
line_atts = { 'style':line_style, 'id':box_id+'-botdraw', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-botdraw', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# Flat Bottom with Lock Flaps
@ -293,26 +298,34 @@ class inkpacking(inkex.EffectExtension):
inicut = 0
line_path = [
[ 'M', [desloc,boxH]],
[ 'l', [ 0, boxD * 1] ],
[ 'l', [ 6, 0 ] ],
[ 'l', [0, boxD]],
[ 'm', [6, 0]],
[ 'l', [0, thck * -2]],
[ 'm', [ 0, thck * 1] ],
[ 'm', [0, thck]],
[ 'l', [boxW - 12, 0]],
[ 'm', [0, thck * -1]],
[ 'l', [0, thck * 2]],
[ 'l', [6, 0 ] ],
[ 'm', [6, 0]],
[ 'l', [0, boxD * -1]],
[ 'M', [desloc, boxH]],
[ 'm', [0, boxD *1]],
[ 'm', [thck, 0]],
[ 'l', [ lockroff , (boxL - thck) * 1 ] ],
[ 'l', [lockroff, (boxL - thck)]],
[ 'l', [boxW - lockroff - lockroff - thck - thck, 0]],
[ 'l', [lockroff , (boxL - thck) * -1 ] ],
[ 'M', [desloc,boxH + thck * 1] ],
[ 'l', [boxW,0] ],
[ 'Z', [] ]
[ 'l', [lockroff, (boxL - thck) * -1]]
]
line_atts = { 'style':line_style, 'id':box_id+'-bothead', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-bothead', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_path = [
[ 'M', [desloc, boxH + boxD]],
[ 'l', [6, 0]],
[ 'M', [desloc + boxW - 6, boxH + boxD]],
[ 'l', [6, 0]],
[ 'M', [desloc,boxH + thck]],
[ 'l', [boxW,0]]
]
line_atts = { 'style':engrave_line_style, 'id':box_id+'-bothead', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if fingergrepa:
@ -320,20 +333,16 @@ class inkpacking(inkex.EffectExtension):
["M", [inicut, boxH]],
["l", [boxW / 2 - fingergrepr, 0]],
["a", [fingergrepr, fingergrepr, 0, 0, 1, fingergrepr * 2,0]],
["l", [boxW / 2 - fingergrepr, 0] ],
["M", [0,0] ],
["Z", [] ]
["l", [boxW / 2 - fingergrepr, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-botcut', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-botcut', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if not fingergrepa:
line_path = [
["M", [inicut, boxH]],
["l", [boxW , 0] ],
["M", [0,0] ],
["Z", [] ]
["l", [boxW, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-botcut', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-botcut', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
@ -347,25 +356,34 @@ class inkpacking(inkex.EffectExtension):
line_path = [
[ 'M', [desloc,0]],
[ 'l', [0, boxD * -1]],
[ 'l', [ 6, 0 ] ],
[ 'm', [6, 0]],
[ 'l', [0, thck * 2]],
[ 'm', [0, thck * -1]],
[ 'l', [boxW - 12, 0]],
[ 'm', [0, thck]],
[ 'l', [0, thck * -2]],
[ 'l', [6, 0 ] ],
[ 'm', [6, 0]],
[ 'l', [0, boxD]],
[ 'M', [desloc, 0]],
[ 'm', [0, boxD *-1]],
[ 'm', [thck, 0]],
[ 'l', [lockroff, (boxL - thck) * -1]],
[ 'l', [boxW - lockroff - lockroff - thck - thck, 0]],
[ 'l', [lockroff , (boxL - thck) ] ],
[ 'M', [desloc,thck * -1] ],
[ 'l', [boxW,0] ],
[ 'Z', [] ]
[ 'l', [lockroff, (boxL - thck)]]
]
line_atts = { 'style':line_style, 'id':box_id+'-tophead', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-tophead', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_path = [
[ 'M', [desloc, boxD * -1]],
[ 'l', [6, 0]],
[ 'M', [desloc + boxW - 6, boxD * -1]],
[ 'l', [6, 0]],
[ 'M', [desloc,thck * -1]],
[ 'l', [boxW,0]]
]
line_atts = { 'style':engrave_line_style, 'id':box_id+'-tophead', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if fingergrepa:
@ -373,20 +391,16 @@ class inkpacking(inkex.EffectExtension):
["M", [inicut,0]],
["l", [boxW / 2 - fingergrepr, 0]],
["a", [fingergrepr, fingergrepr, 0, 0, 0, fingergrepr * 2,0]],
["l", [boxW / 2 - fingergrepr, 0] ],
["M", [0,0] ],
["Z", [] ]
["l", [boxW / 2 - fingergrepr, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-topcut', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-topcut', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if not fingergrepa:
line_path = [
["M", [inicut,0]],
["l", [boxW , 0] ],
["M", [0,0] ],
["Z", [] ]
["l", [boxW, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-topcut', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-topcut', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# Rounded Bottom with Lock Flaps
@ -398,26 +412,34 @@ class inkpacking(inkex.EffectExtension):
inicut = 0
line_path = [
[ 'M', [desloc,boxH]],
[ 'l', [ 0, boxD * 1] ],
[ 'l', [ 6, 0 ] ],
[ 'l', [0, boxD]],
[ 'm', [6, 0]],
[ 'l', [0, thck * -2]],
[ 'm', [ 0, thck * 1] ],
[ 'm', [0, thck]],
[ 'l', [boxW - 12, 0]],
[ 'm', [0, thck * -1]],
[ 'l', [0, thck * 2]],
[ 'l', [6, 0 ] ],
[ 'm', [6, 0]],
[ 'l', [0, boxD * -1]],
[ 'M', [desloc, boxH]],
[ 'm', [0, boxD * 1] ],
[ 'm', [0, boxD]],
[ 'm', [thck, 0]],
[ 'a', [lockrr , lockrr , 0 , 0 , 0, lockroff , (boxL - thck) * 1 ] ],
[ 'a', [lockrr , lockrr, 0, 0, 0, lockroff, (boxL - thck)]],
[ 'l', [boxW - lockroff - lockroff - thck - thck, 0]],
[ 'a', [lockrr , lockrr , roto , 0 , 0, lockroff , (boxL - thck) * - 1 ] ],
[ 'M', [desloc,boxH + thck * 1] ],
[ 'l', [boxW,0] ],
[ 'Z', [] ]
[ 'a', [lockrr, lockrr, roto, 0, 0, lockroff, (boxL - thck) * - 1]]
]
line_atts = { 'style':line_style, 'id':box_id+'-bothead', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-bothead', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_path = [
[ 'M', [desloc, boxH + boxD]],
[ 'l', [6, 0]],
[ 'M', [desloc + boxW - 6, boxH + boxD]],
[ 'l', [6, 0]],
[ 'M', [desloc,boxH + thck]],
[ 'l', [boxW,0]]
]
line_atts = { 'style':engrave_line_style, 'id':box_id+'-bothead', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if fingergrepa:
@ -425,20 +447,16 @@ class inkpacking(inkex.EffectExtension):
["M", [inicut,boxH]],
["l", [boxW / 2 - fingergrepr, 0]],
["a", [fingergrepr, fingergrepr, 0, 0, 1, fingergrepr * 2,0]],
["l", [boxW / 2 - fingergrepr, 0] ],
["M", [0,0] ],
["Z", [] ]
["l", [boxW / 2 - fingergrepr, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-botcut', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-botcut', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if not fingergrepa:
line_path = [
["M", [inicut,boxH]],
["l", [boxW , 0] ],
["M", [0,0] ],
["Z", [] ]
["l", [boxW, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-botcut', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-botcut', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# Rounded Top with Lock Flaps
@ -451,52 +469,55 @@ class inkpacking(inkex.EffectExtension):
line_path = [
[ 'M', [desloc,0]],
[ 'l', [0, boxD * -1]],
[ 'l', [ 6, 0 ] ],
[ 'm', [6, 0]],
[ 'l', [0, thck * 2]],
[ 'm', [0, thck * -1]],
[ 'l', [boxW - 12, 0]],
[ 'm', [0, thck]],
[ 'l', [0, thck * -2]],
[ 'l', [6, 0 ] ],
[ 'm', [6, 0]],
[ 'l', [0, boxD]],
[ 'M', [desloc, 0]],
[ 'm', [0, boxD *-1]],
[ 'm', [thck, 0]],
[ 'a', [lockrr , lockrr, 0, 0, 1, lockroff, (boxL - thck) * -1]],
[ 'l', [boxW - lockroff - lockroff - thck - thck, 0]],
[ 'a', [lockrr , lockrr , roto , 0 , 1, lockroff , (boxL - thck) ] ],
[ 'M', [desloc,thck * -1] ],
[ 'l', [boxW,0] ],
[ 'Z', [] ]
[ 'a', [lockrr, lockrr, roto, 0, 1, lockroff, (boxL - thck)]]
]
line_atts = { 'style':line_style, 'id':box_id+'-tophead', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-tophead', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_path = [
[ 'M', [desloc, boxD * -1]],
[ 'l', [6, 0]],
[ 'M', [desloc + boxW - 6, boxD * -1]],
[ 'l', [6, 0]],
[ 'M', [desloc,thck * -1]],
[ 'l', [boxW,0]]
]
line_atts = { 'style':engrave_line_style, 'id':box_id+'-tophead', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if fingergrepa:
line_path = [
["M", [inicut,0]],
["l", [boxW / 2 - fingergrepr, 0]],
["a", [fingergrepr, fingergrepr, 0, 0, 0, fingergrepr * 2,0]],
["l", [boxW / 2 - fingergrepr, 0] ],
["M", [0,0] ],
["Z", [] ]
["l", [boxW / 2 - fingergrepr, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-topcut', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-topcut', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if not fingergrepa:
line_path = [
["M", [inicut,0]],
["l", [boxW , 0] ],
["M", [0,0] ],
["Z", [] ]
["l", [boxW, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-topcut', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-topcut', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# HotMelt Top
if tpsc == "fwnf":
if tfal:
line_path = [
cut_line_path = [
[ 'M', [0, 0]],
[ 'L', [0, boxD * -1]],
[ 'L', [boxW, boxD * -1]],
@ -509,18 +530,16 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW + boxD + boxW, 0]],
[ 'M', [boxW + boxD + boxW, boxD * -1 /2]],
[ 'M', [boxW + boxD + boxW + boxD - thck, boxD * -1 /2]],
[ 'M', [ boxW + boxD + boxW + boxD - thck, 0 ] ],
[ 'M', [boxW + boxD + boxW + boxD - thck, 0]]
]
engrave_line_path = [
[ 'M', [0, 0 - thck]],
[ 'L', [boxW, 0 - thck]],
[ 'M', [boxW + boxD, 0 - thck]],
[ 'L', [ boxW + boxD + boxW , 0 - thck ] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW, 0 - thck]]
]
line_atts = { 'style':line_style, 'id':box_id+'-topdraw', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if not tfal:
line_path = [
cut_line_path = [
[ 'M', [0, 0]],
[ 'L', [0, boxD * -1 * hotmeltp]],
[ 'L', [boxW, boxD * -1 * hotmeltp]],
@ -533,66 +552,69 @@ class inkpacking(inkex.EffectExtension):
[ 'L', [boxW + boxD + boxW, 0]],
[ 'M', [boxW + boxD + boxW, boxD * -1 /2]],
[ 'M', [boxW + boxD + boxW + boxD - thck, boxD * -1 /2]],
[ 'M', [ boxW + boxD + boxW + boxD - thck, 0 ] ],
[ 'M', [boxW + boxD + boxW + boxD - thck, 0]]
]
engrave_line_path = [
[ 'M', [0, 0 - thck]],
[ 'L', [boxW, 0 - thck]],
[ 'M', [boxW + boxD, 0 - thck]],
[ 'L', [ boxW + boxD + boxW , 0 - thck ] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW, 0 - thck]]
]
line_atts = { 'style':line_style, 'id':box_id+'-topdraw', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-topdraw_cut', 'd':str(Path(cut_line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_atts = { 'style':engrave_line_style, 'id':box_id+'-topdraw_engrave', 'd':str(Path(engrave_line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# HotMelt Bottom
if btsc == "fwnf":
if bfal:
line_path = [
cut_line_path = [
[ 'M', [0, boxH]],
[ 'L', [ 0, boxH + boxD * 1 ] ],
[ 'L', [ boxW, boxH + boxD * 1 ] ],
[ 'L', [0, boxH + boxD]],
[ 'L', [boxW, boxH + boxD]],
[ 'L', [boxW, boxH]],
[ 'M', [ boxW, boxH + boxD * 1 / 2 ] ],
[ 'M', [ boxW + boxD, boxH + boxD * 1 / 2 ] ],
[ 'M', [boxW, boxH + boxD / 2]],
[ 'M', [boxW + boxD, boxH + boxD / 2]],
[ 'M', [boxW + boxD, boxH]],
[ 'L', [ boxW + boxD, boxH + boxD * 1 * hotmeltp ] ],
[ 'L', [ boxW + boxD + boxW, boxH + boxD * 1 * hotmeltp ] ],
[ 'L', [boxW + boxD, boxH + boxD * hotmeltp]],
[ 'L', [boxW + boxD + boxW, boxH + boxD * hotmeltp]],
[ 'L', [boxW + boxD + boxW, boxH]],
[ 'M', [ boxW + boxD + boxW, boxH + boxD * 1 /2 ] ],
[ 'M', [ boxW + boxD + boxW + boxD - thck, boxH + boxD * 1 /2 ] ],
[ 'M', [ boxW + boxD + boxW + boxD - thck, boxH ] ],
[ 'M', [boxW + boxD + boxW, boxH + boxD /2]],
[ 'M', [boxW + boxD + boxW + boxD - thck, boxH + boxD /2]],
[ 'M', [boxW + boxD + boxW + boxD - thck, boxH]]
]
engrave_line_path = [
[ 'M', [0, boxH + thck]],
[ 'L', [boxW, boxH + thck]],
[ 'M', [boxW + boxD, boxH + thck]],
[ 'L', [ boxW + boxD + boxW , boxH + thck ] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW, boxH + thck]]
]
line_atts = { 'style':line_style, 'id':box_id+'-botdraw', 'd':str(Path(line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if not bfal:
line_path = [
cut_line_path = [
[ 'M', [0, boxH]],
[ 'L', [ 0, boxH + boxD * 1 * hotmeltp ] ],
[ 'L', [ boxW, boxH + boxD * 1 * hotmeltp ] ],
[ 'L', [0, boxH + boxD * hotmeltp]],
[ 'L', [boxW, boxH + boxD * hotmeltp]],
[ 'L', [boxW, boxH]],
[ 'M', [ boxW, boxH + boxD * 1 / 2 ] ],
[ 'M', [ boxW + boxD, boxH + boxD * 1 / 2 ] ],
[ 'M', [boxW, boxH + boxD / 2]],
[ 'M', [boxW + boxD, boxH + boxD / 2]],
[ 'M', [boxW + boxD, boxH]],
[ 'L', [ boxW + boxD, boxH + boxD * 1 ] ],
[ 'L', [ boxW + boxD + boxW, boxH + boxD * 1 ] ],
[ 'L', [boxW + boxD, boxH + boxD]],
[ 'L', [boxW + boxD + boxW, boxH + boxD]],
[ 'L', [boxW + boxD + boxW, boxH]],
[ 'M', [ boxW + boxD + boxW, boxH + boxD * 1 /2 ] ],
[ 'M', [ boxW + boxD + boxW + boxD - thck, boxH + boxD * 1 /2 ] ],
[ 'M', [ boxW + boxD + boxW + boxD - thck, boxH ] ],
[ 'M', [boxW + boxD + boxW, boxH + boxD /2]],
[ 'M', [boxW + boxD + boxW + boxD - thck, boxH + boxD /2]],
[ 'M', [boxW + boxD + boxW + boxD - thck, boxH]]
]
engrave_line_path = [
[ 'M', [0, boxH + thck]],
[ 'L', [boxW, boxH + thck]],
[ 'M', [boxW + boxD, boxH + thck]],
[ 'L', [ boxW + boxD + boxW , boxH + thck ] ],
[ 'Z', [] ]
[ 'L', [boxW + boxD + boxW, boxH + thck]]
]
line_atts = { 'style':line_style, 'id':box_id+'-botdraw', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-botdraw_cut', 'd':str(Path(cut_line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_atts = { 'style':engrave_line_style, 'id':box_id+'-botdraw_engrave', 'd':str(Path(engrave_line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
thck2 = thck / 2
# Top Glue Flaps
@ -601,7 +623,7 @@ class inkpacking(inkex.EffectExtension):
if tpsc == "fwnf":
desclock = 0
if tfal:
line_path = [
cut_line_path = [
[ 'M', [boxW, 0]],
[ 'l', [0, glueflapinoff * -1]],
[ 'l', [glueflapin45, glueflapin45 * -1]],
@ -612,8 +634,6 @@ class inkpacking(inkex.EffectExtension):
[ 'l', [glueflapou45 * -1, glueflapou45 * -1]],
[ 'l', [glueflapoudesl * -1, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) * -1 + thck2]],
[ 'l', [(boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock) * -1, 0]],
[ 'M', [ boxW , 0 ] ],
[ 'l', [ boxD - desclock , 0 ] ],
[ 'M', [boxW + boxW + boxD + boxD - thck, 0]],
[ 'l', [0, glueflapinoff * -1]],
[ 'l', [glueflapin45 * -1, glueflapin45 * -1]],
@ -623,16 +643,18 @@ class inkpacking(inkex.EffectExtension):
[ 'l', [0, glueflapouoff * -1]],
[ 'l', [glueflapou45, glueflapou45 * -1]],
[ 'l', [glueflapoudesl, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) * -1 + thck2]],
[ 'l', [ (boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock -thck ) , 0 ] ],
[ 'l', [(boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock -thck ), 0]]
]
engrave_line_path = [
[ 'M', [boxW, 0]],
[ 'l', [boxD - desclock, 0]],
[ 'M', [boxW + boxD + boxW + desclock, 0]],
[ 'l', [ boxD - thck - desclock , 0 ] ],
[ 'Z', [] ]
[ 'l', [boxD - thck - desclock, 0]]
]
if not tfal:
line_path = [
cut_line_path = [
[ 'M', [boxW + boxD, 0]],
[ 'l', [0, glueflapinoff * -1]],
[ 'l', [glueflapin45 * -1, glueflapin45 * -1]],
[ 'l', [glueflapindesl * -1, ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) * -1 + thck2]],
@ -642,9 +664,6 @@ class inkpacking(inkex.EffectExtension):
[ 'l', [glueflapou45, glueflapou45 * -1]],
[ 'l', [glueflapoudesl, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) * -1 + thck2]],
[ 'l', [(boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock), 0]],
[ 'M', [ boxW + desclock , 0 ] ],
[ 'l', [ boxD - desclock , 0 ] ],
[ 'M', [boxW + boxD + boxW, 0]],
[ 'l', [0, glueflapinoff * -1]],
[ 'l', [glueflapin45, glueflapin45 * -1]],
@ -654,15 +673,20 @@ class inkpacking(inkex.EffectExtension):
[ 'l', [0, glueflapouoff * -1]],
[ 'l', [glueflapou45 * -1, glueflapou45 * -1]],
[ 'l', [glueflapoudesl * -1, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) * -1 + thck2]],
[ 'l', [ (boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock -thck) * -1, 0 ] ],
[ 'l', [(boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock -thck) * -1, 0]]
]
engrave_line_path = [
[ 'M', [boxW + desclock, 0]],
[ 'l', [boxD - desclock, 0]],
[ 'M', [boxW + boxD + boxW, 0]],
[ 'l', [ boxD -thck - desclock , 0 ] ],
[ 'Z', [] ]
[ 'l', [boxD -thck - desclock, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-topglueflap', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-topglueflap_cut', 'd':str(Path(cut_line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_atts = { 'style':engrave_line_style, 'id':box_id+'-topglueflap_engrave', 'd':str(Path(engrave_line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
# Bottom Glue Flaps
if not usetop:
@ -678,67 +702,71 @@ class inkpacking(inkex.EffectExtension):
if btsc == "fwnf":
desclock = 0
if bfal:
line_path = [
cut_line_path = [
[ 'M', [boxW, boxH]],
[ 'l', [ 0, glueflapinoff * 1] ],
[ 'l', [ glueflapin45, glueflapin45 * 1] ],
[ 'l', [ glueflapindesl, ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) * 1 -thck2] ],
[ 'l', [0, glueflapinoff]],
[ 'l', [glueflapin45, glueflapin45]],
[ 'l', [glueflapindesl, ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) -thck2]],
[ 'M', [boxW + boxD, boxH]],
[ 'l', [desclock * -1, 0]],
[ 'l', [ 0, glueflapouoff * 1] ],
[ 'l', [ glueflapou45 * -1, glueflapou45 * 1] ],
[ 'l', [ glueflapoudesl * -1, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) * 1 -thck2 ] ],
[ 'l', [0, glueflapouoff]],
[ 'l', [glueflapou45 * -1, glueflapou45]],
[ 'l', [glueflapoudesl * -1, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) -thck2]],
[ 'l', [(boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock) * -1, 0]],
[ 'M', [ boxW , boxH ] ],
[ 'l', [ boxD - desclock , 0 ] ],
[ 'M', [boxW + boxW + boxD + boxD - thck, boxH]],
[ 'l', [ 0, glueflapinoff * 1] ],
[ 'l', [ glueflapin45 * -1, glueflapin45 * 1] ],
[ 'l', [ glueflapindesl * -1 , ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) * 1 - thck2] ],
[ 'l', [0, glueflapinoff]],
[ 'l', [glueflapin45 * -1, glueflapin45]],
[ 'l', [glueflapindesl * -1, ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) - thck2]],
[ 'M', [boxW + boxD + boxW, boxH]],
[ 'l', [desclock, 0]],
[ 'l', [ 0, glueflapouoff * 1] ],
[ 'l', [ glueflapou45 , glueflapou45 * 1] ],
[ 'l', [ glueflapoudesl , ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) * 1 -thck2] ],
[ 'l', [ (boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock -thck ) , 0 ] ],
[ 'l', [0, glueflapouoff]],
[ 'l', [glueflapou45, glueflapou45]],
[ 'l', [glueflapoudesl, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) -thck2]],
[ 'l', [(boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock -thck ), 0]]
]
engrave_line_path = [
[ 'M', [boxW, boxH]],
[ 'l', [boxD - desclock, 0]],
[ 'M', [boxW + boxD + boxW + desclock, boxH]],
[ 'l', [ boxD - thck - desclock , 0 ] ],
[ 'Z', [] ]
[ 'l', [boxD - thck - desclock, 0]]
]
if not bfal:
line_path = [
cut_line_path = [
[ 'M', [boxW + boxD, boxH]],
[ 'l', [ 0, glueflapinoff * 1] ],
[ 'l', [ glueflapin45 * -1, glueflapin45 * 1] ],
[ 'l', [ glueflapindesl * -1 , ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) * 1 - thck2] ],
[ 'l', [0, glueflapinoff]],
[ 'l', [glueflapin45 * -1, glueflapin45]],
[ 'l', [glueflapindesl * -1, ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) - thck2]],
[ 'M', [boxW, boxH]],
[ 'l', [desclock, 0]],
[ 'l', [ 0, glueflapouoff * 1] ],
[ 'l', [ glueflapou45 , glueflapou45 * 1] ],
[ 'l', [ glueflapoudesl , ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) * 1 - thck2] ],
[ 'l', [0, glueflapouoff]],
[ 'l', [glueflapou45, glueflapou45]],
[ 'l', [glueflapoudesl, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) - thck2]],
[ 'l', [(boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock), 0]],
[ 'M', [ boxW + desclock , boxH ] ],
[ 'l', [ boxD - desclock , 0 ] ],
[ 'M', [boxW + boxD + boxW, boxH]],
[ 'l', [ 0, glueflapinoff * 1] ],
[ 'l', [ glueflapin45, glueflapin45 * 1] ],
[ 'l', [ glueflapindesl, ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) * 1 - thck2] ],
[ 'l', [0, glueflapinoff]],
[ 'l', [glueflapin45, glueflapin45]],
[ 'l', [glueflapindesl, ((boxD + boxL) / 2 - glueflapinoff - glueflapin45) - thck2]],
[ 'M', [boxW + boxD + boxW + boxD - thck, boxH]],
[ 'l', [desclock * -1, 0]],
[ 'l', [ 0, glueflapouoff * 1] ],
[ 'l', [ glueflapou45 * -1, glueflapou45 * 1] ],
[ 'l', [ glueflapoudesl * -1, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) * 1 - thck2] ],
[ 'l', [ (boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock -thck) * -1, 0 ] ],
[ 'l', [0, glueflapouoff]],
[ 'l', [glueflapou45 * -1, glueflapou45]],
[ 'l', [glueflapoudesl * -1, ((boxD + boxL) / 2 - glueflapouoff - glueflapou45) - thck2]],
[ 'l', [(boxD - glueflapindesl - glueflapoudesl - glueflapin45 - glueflapou45 - desclock -thck) * -1, 0]]
]
engrave_line_path = [
[ 'M', [boxW + desclock, boxH]],
[ 'l', [boxD - desclock, 0]],
[ 'M', [boxW + boxD + boxW, boxH]],
[ 'l', [ boxD -thck - desclock , 0 ] ],
[ 'Z', [] ]
[ 'l', [boxD -thck - desclock, 0]]
]
line_atts = { 'style':line_style, 'id':box_id+'-botglueflap', 'd':str(Path(line_path)) }
line_atts = { 'style':cut_line_style, 'id':box_id+'-botglueflap_cut', 'd':str(Path(cut_line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
line_atts = { 'style':engrave_line_style, 'id':box_id+'-botglueflap_engrave', 'd':str(Path(engrave_line_path)) }
etree.SubElement(g, inkex.addNS('path','svg'), line_atts )
if __name__ == '__main__':
inkpacking().run()