This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/estucheria/fablabchemnitz_automaticbottomcase.py

244 lines
10 KiB
Python
Raw Normal View History

2020-07-31 00:14:03 +02:00
#! /usr/bin/env python3
2020-07-30 01:16:18 +02:00
#
#
2020-07-31 00:14:03 +02:00
# This script draws the outer profile of the box cut in a single
# closed path and then add the other necessary strips with colours
# different to identify them.
# red > for cuts and outer profile
# blue > for crevices
# green > for drills
# yellow > half-cut
2020-07-30 01:16:18 +02:00
#
2020-07-31 00:14:03 +02:00
# EVERYTHING:
# add cm/in drawing option
# move drawing to the center of the document
2020-07-30 01:16:18 +02:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
__version__ = "0.2"
import inkex
2020-07-31 00:14:03 +02:00
class AutomaticBottomCase(inkex.EffectExtension):
2020-07-30 01:16:18 +02:00
def add_arguments(self, pars):
2020-07-31 00:14:03 +02:00
pars.add_argument("--width", type=float, default=25.0, help="Width of the box")
pars.add_argument("--height", type=float, default=25.0, help="Height of the box")
pars.add_argument("--depth", type=float, default=25.0, help="Length of the box")
pars.add_argument("--glue_tab", type=float, default=5.0, help="Tab width")
pars.add_argument("--close_tab", type=float, default=5.0, help="Height sealing flange")
pars.add_argument("--side_tabs", type=float, default=5.0, help="Height side sealing flanges")
pars.add_argument("--unit", default="mm", help="Type of units")
2020-07-30 01:16:18 +02:00
def effect(self):
2020-07-31 00:14:03 +02:00
width_center_document = self.svg.unittouu(self.document.getroot().get('width'))/2
height_center_document = self.svg.unittouu(self.document.getroot().get('height'))/2
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
eyelash_measure1=5
eyelash_measure2=1
eyelash_measure3=4
eyelash_measure4=3
box_width = self.svg.unittouu(str(self.options.width) + self.options.unit)
box_height = self.svg.unittouu(str(self.options.height) + self.options.unit)
box_length = self.svg.unittouu(str(self.options.depth) + self.options.unit)
glue_width = self.svg.unittouu(str(self.options.glue_tab) + self.options.unit)
top_flap_closure = self.svg.unittouu(str(self.options.close_tab) + self.options.unit)
top_flap = self.svg.unittouu(str(self.options.side_tabs) + self.options.unit)
2020-07-30 01:16:18 +02:00
if self.options.unit=="cm":
2020-07-31 00:14:03 +02:00
eyelash_measure1=0.5
eyelash_measure2=0.1
eyelash_measure3=0.4
eyelash_measure3=0.3
2020-07-30 01:16:18 +02:00
if self.options.unit=='in':
2020-07-31 00:14:03 +02:00
eyelash_measure1=0.196
eyelash_measure2=0.039
eyelash_measure3=0.157
eyelash_measure3=0.118
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
measure1_side_blind=self.svg.unittouu(str(eyelash_measure1) + self.options.unit)
measure2_side_blind=self.svg.unittouu(str(eyelash_measure2) + self.options.unit)
measure3_side_blind=self.svg.unittouu(str(eyelash_measure3) + self.options.unit)
measure4_side_blind=self.svg.unittouu(str(eyelash_measure4) + self.options.unit)
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
box_id = self.svg.get_unique_id('automaticbottomcase')
group = self.svg.get_current_layer().add(inkex.Group(id=box_id))
line_style_cuts = {'stroke': '#FF0000', 'fill': 'none', 'stroke-width': str(self.svg.unittouu('1px'))}
cleft_line_style = {'stroke': '#0000FF', 'fill': 'none', 'stroke-width': str(self.svg.unittouu('1px'))}
line_style_drills = {'stroke': '#00FF00', 'fill': 'none', 'stroke-width': str(self.svg.unittouu('1px'))}
media_line_style = {'stroke': '#00FFFF', 'fill': 'none', 'stroke-width': str(self.svg.unittouu('1px'))}
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
# line.path --> M = absolute coordinates
# line.path --> l = draws a line from the current point to the specified coordinates
# line.path --> c = draws a beizer curve from the current point to the specified coordinates
# line.path --> q = draws an arc from the current point to the specified coordinates using a point as reference
# line.path --> Z = close path
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
#Outside profile of the box
line = group.add(inkex.PathElement(id=box_id + '-profile-outside'))
2020-07-30 01:16:18 +02:00
line.path = [
['M', [0, 0]],
2020-07-31 00:14:03 +02:00
['l', [0, 0-box_length]],
['l', [0, 0]],
['q', [0,0-top_flap_closure,top_flap_closure, 0-top_flap_closure]],
['l', [box_width-(top_flap_closure*2), 0]],
['q', [top_flap_closure,0,top_flap_closure,top_flap_closure]],
['l', [0, 0]],
['l', [0, (box_length)]],
['l', [measure4_side_blind, 0-measure4_side_blind]],
['l', [0,0-(top_flap-measure4_side_blind)]],
['l', [(box_length-measure2_side_blind-measure3_side_blind-measure4_side_blind), 0]],
['l', [measure3_side_blind, (top_flap-measure2_side_blind-measure1_side_blind)]],
['l', [measure2_side_blind, measure2_side_blind]],
['l', [0, measure1_side_blind]],
['l', [0,0]],
['l', [box_width, 0]],
['l', [0,0]],
['l', [0, 0]],
['l', [0, 0-measure1_side_blind]],
['l', [measure2_side_blind, 0-measure2_side_blind]],
['l', [measure3_side_blind, 0-(top_flap-measure2_side_blind-measure1_side_blind)]],
['l', [(box_length-measure2_side_blind-measure3_side_blind-measure4_side_blind), 0]],
['l', [0,top_flap-measure4_side_blind]],
['l', [measure4_side_blind, measure4_side_blind]],
['l', [0, box_height]],
['l', [0-((box_length/2)),box_length/2]],
['l', [0-((box_length/2)-(measure2_side_blind)*2),0]],
['l', [0-(measure2_side_blind),0-((box_length/2)-measure2_side_blind)]],
['l', [0-measure2_side_blind,0-measure2_side_blind]],
['l', [0-measure2_side_blind,measure2_side_blind]],
['l', [0,box_length*0.7]],
['l', [0-(((box_length*0.5)-measure2_side_blind)/2),0]],
['l', [0-(((box_length*0.5)-measure2_side_blind)/2),0-((box_length*0.7)-(box_length*0.5))]],
['l', [0-((box_width/2)-((box_length*0.5)-measure2_side_blind)),0]],
['l', [measure3_side_blind,measure3_side_blind]],
['l', [0-((box_length*0.7)-(box_length*0.5))-measure3_side_blind,((box_length*0.7)-(box_length*0.5))-measure3_side_blind]],
['l', [0-(((box_width/2)-((box_length*0.5)))+((box_length*0.7)-(box_length*0.5))),0]],
['l', [0-measure4_side_blind/2,0-((box_length*0.7))-measure2_side_blind]],
['l', [0-(box_length/2),box_length/2]],
['l', [0-((box_length/2)-(measure2_side_blind)*2),0]],
['l', [0-measure2_side_blind,0-((box_length/2)-measure2_side_blind)]],
['l', [0-measure2_side_blind,0-measure2_side_blind]],
['l', [0-measure2_side_blind,measure2_side_blind]],
['l', [0,box_length*0.7]],
['l', [0-(((box_length*0.5)-measure2_side_blind)/2),0]],
['l', [0-(((box_length*0.5)-measure2_side_blind)/2),0-((box_length*0.7)-(box_length*0.5))]],
['l', [0-((box_width/2)-((box_length*0.5)-measure2_side_blind)),0]],
['l', [measure3_side_blind,measure3_side_blind]],
['l', [0-((box_length*0.7)-(box_length*0.5))-measure3_side_blind,((box_length*0.7)-(box_length*0.5))-measure3_side_blind]],
['l', [0-(((box_width/2)-((box_length*0.5)))+((box_length*0.7)-(box_length*0.5))),0]],
['l', [0-measure4_side_blind/2,0-((box_length*0.7))-measure2_side_blind]],
['l', [0, 0-measure2_side_blind]],
['l', [0-glue_width, 0-(glue_width/2)]],
['l', [0, 0-(box_height-glue_width-(measure2_side_blind*2))]],
['l', [glue_width, 0-(glue_width/2)]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = line_style_cuts
2020-07-30 01:16:18 +02:00
#Hendidos
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-1'))
2020-07-30 01:16:18 +02:00
line.path = [
['M', [0,0]],
2020-07-31 00:14:03 +02:00
['l', [0,box_height]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-2'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [box_width,0]],
['l', [0,box_height]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-3'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [box_width+box_length,0]],
['l', [0,box_height]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-4'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [box_width+box_width+box_length,0]],
['l', [0,box_height]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-5'))
2020-07-30 01:16:18 +02:00
line.path = [
['M', [0,0]],
2020-07-31 00:14:03 +02:00
['l', [box_width,0]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-6'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [0,box_height]],
['l', [((box_length+box_width)*2),0]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-7'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [box_width,0]],
['l', [box_length,0]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-8'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [box_length+box_width*2,0]],
['l', [box_length,0]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-splits-9'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [0,0-(box_length)]],
['l', [box_width,0]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = cleft_line_style
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-drill-1'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [box_width-measure2_side_blind,box_height+measure2_side_blind]],
['l', [0-((box_length*0.5)),(box_length*0.5)]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = line_style_drills
2020-07-30 01:16:18 +02:00
2020-07-31 00:14:03 +02:00
line = group.add(inkex.PathElement(id=box_id + '-profile-drill-2'))
2020-07-30 01:16:18 +02:00
line.path = [
2020-07-31 00:14:03 +02:00
['M', [((box_width*2)+box_length)-measure2_side_blind,box_height+measure2_side_blind]],
['l', [0-((box_length*0.5)),(box_length*0.5)]],
2020-07-30 01:16:18 +02:00
['Z', []]
]
2020-07-31 00:14:03 +02:00
line.style = line_style_drills
2020-07-30 01:16:18 +02:00
if __name__ == '__main__':
2020-07-31 00:14:03 +02:00
AutomaticBottomCase().run()