small adjustments in polyhedra
This commit is contained in:
parent
5778c1c9ee
commit
89128a94ef
@ -52,6 +52,8 @@
|
|||||||
<option value="2">Single Tabs</option>
|
<option value="2">Single Tabs</option>
|
||||||
<option value="3">None</option>
|
<option value="3">None</option>
|
||||||
</param>
|
</param>
|
||||||
|
<param name="material_thickness" type="float" min="0.01" max="1000.0" gui-text="material thickness">1.0</param>
|
||||||
|
<label>Hint: Stroke widths within the generated output may differ. Please adjust manually (reason: scale transforms)</label>
|
||||||
<effect>
|
<effect>
|
||||||
<object-type>all</object-type>
|
<object-type>all</object-type>
|
||||||
<effects-menu>
|
<effects-menu>
|
||||||
|
@ -34,32 +34,13 @@ def points_to_svgd(p):
|
|||||||
svgd += 'L%.3f,%.3f' % x
|
svgd += 'L%.3f,%.3f' % x
|
||||||
return svgd
|
return svgd
|
||||||
|
|
||||||
# these are designed to be 100px wide - they have to be scaled
|
|
||||||
no_tab = { 'cut' : ['m 0,0 100,0'], 'perf' : []}
|
|
||||||
|
|
||||||
notab = {0 : no_tab}
|
|
||||||
simpletab = {0: {'cut': ['m 0,0 20,19 60,0 l 20,-19'], 'perf' : ['m 0,0 100,0']}}
|
|
||||||
# tab array - 0 = slot/tab, 1 = two tabs, 2 = single tab (alternate tab and nothing), 3 = none
|
|
||||||
tabStyle = [{ \
|
|
||||||
50 : {'cut': ['m 0,0 35,0 0,2 -6,0 c 0,0 1,8 6,12 8,6 22,6 30,0 5,-4 6,-12 6,-12 l -6,0 0,-2 35,0'], 'perf' : ['M 42,0 58,0']}, \
|
|
||||||
24 : {'cut': ['m 0,0 55,0 0,2 -6,0 c 0,0 1,3 6,6 8,3 19,6 27,8 5,-4 9,-14 9,-14 l -6,0 0,-2 15,0'], 'perf' : ['M 62,0 78,0']}, \
|
|
||||||
18 : {'cut' : ['m 0,0 65,0 0,2 -6,0 c 0,0 1,3 6,6 8,2 11,2 19,3 5,-4 9,-10 7,-9 l -6,0 0,-2 15,0'], 'perf' : ['m 72,0 6,0']}, \
|
|
||||||
6 : {'cut': ['m 0,0 70,0 2,7 10,1 5,-6 -2,0 0,-2 15,0'], 'perf' : ['m 74,0 7,0']},
|
|
||||||
0 : { 'cut' : ['m 0,0 100,0'], 'perf' : []}}, simpletab, simpletab, notab]
|
|
||||||
slotStyle = [{\
|
|
||||||
50: {'cut': ['m 0,0 20,19 60,0 l 20,-19','m 28,-3 4,5 36,0 4,-5'], 'perf' : ['M 0,0 28,0','M 100,0 72,0']}, \
|
|
||||||
24 : {'cut': ['M 100,0 90,18 30,11 20,0 0,0', 'm 92,-3 -4,5 -36,0 -4,-5'], 'perf' : ['M 100,0 92,0', 'M 20,0 48,0']}, \
|
|
||||||
18 : {'cut' : ['M 100,0 90,16 40,9 35,0 0,0', 'm 92,-3 -4,5 -26,0 -4,-5'], 'perf' : ['M 100,0 92,0', 'M 35,0 58,0']}, \
|
|
||||||
6 : {'cut' : ['M 100,0 98,10 88,9 84,2 86,2 86,0 0,0'], 'perf' : ['m 96,0 -6,0']},
|
|
||||||
0 : { 'cut' : ['m 0,0 100,0'], 'perf' : [] }}, simpletab, notab, notab]
|
|
||||||
|
|
||||||
|
|
||||||
class Polyhedra(inkex.EffectExtension):
|
class Polyhedra(inkex.EffectExtension):
|
||||||
|
|
||||||
def add_arguments(self, pars):
|
def add_arguments(self, pars):
|
||||||
pars.add_argument("-p", "--poly", default='Cube', help="Polygon net to render")
|
pars.add_argument("-p", "--poly", default="Cube", help="Polygon net to render")
|
||||||
pars.add_argument("-s", "--size", type=float, default=100.0, help="Size of first edge")
|
pars.add_argument("-s", "--size", type=float, default=100.0, help="Size of first edge")
|
||||||
pars.add_argument("-u", "--unit", default= 'mm', help="Units")
|
pars.add_argument("-u", "--unit", default="mm", help="Units")
|
||||||
|
pars.add_argument("-m", "--material_thickness", type=float, default=1.0, help="Material thickness")
|
||||||
pars.add_argument("-t", "--tabs", type=int, default=0, help="Tab style")
|
pars.add_argument("-t", "--tabs", type=int, default=0, help="Tab style")
|
||||||
|
|
||||||
def get_tab(self, limitAngle):
|
def get_tab(self, limitAngle):
|
||||||
@ -68,6 +49,28 @@ class Polyhedra(inkex.EffectExtension):
|
|||||||
def get_slot(self, limitAngle):
|
def get_slot(self, limitAngle):
|
||||||
return(self.get_connector('slot', limitAngle))
|
return(self.get_connector('slot', limitAngle))
|
||||||
|
|
||||||
|
def get_slot_tab_style(self):
|
||||||
|
# these are designed to be 100px wide - they have to be scaled
|
||||||
|
no_tab = { 'cut' : ['m 0,0 100,0'], 'perf' : []}
|
||||||
|
|
||||||
|
notab = {0 : no_tab}
|
||||||
|
simpletab = {0: {'cut': ['m 0,0 20,19 60,0 l 20,-19'], 'perf' : ['m 0,0 100,0']}}
|
||||||
|
# tab array - 0 = slot/tab, 1 = two tabs, 2 = single tab (alternate tab and nothing), 3 = none
|
||||||
|
mt = self.options.material_thickness
|
||||||
|
tabStyle = [{ \
|
||||||
|
50 : {'cut': ['m 0,0 35,0 0,{} -6,0 c 0,0 1,8 6,12 8,6 22,6 30,0 5,-4 6,-12 6,-12 l -6,0 0,{} 35,0'.format(mt,-mt)], 'perf' : ['M 42,0 58,0']}, \
|
||||||
|
24 : {'cut': ['m 0,0 55,0 0,{} -6,0 c 0,0 1,3 6,6 8,3 19,6 27,8 5,-4 9,-14 9,-14 l -6,0 0,{} 15,0'.format(mt,-mt)], 'perf' : ['M 62,0 78,0']}, \
|
||||||
|
18 : {'cut': ['m 0,0 65,0 0,{} -6,0 c 0,0 1,3 6,6 8,2 11,2 19,3 5,-4 9,-10 7,-9 l -6,0 0,{} 15,0'.format(mt,-mt)], 'perf' : ['m 72,0 6,0']}, \
|
||||||
|
6 : {'cut': ['m 0,0 70,0 {},7 10,1 5,-6 -2,0 0,{} 15,0'.format(mt,-mt)], 'perf' : ['m 74,0 7,0']},
|
||||||
|
0 : {'cut': ['m 0,0 100,0'], 'perf' : []}}, simpletab, simpletab, notab]
|
||||||
|
slotStyle = [{\
|
||||||
|
50 : {'cut': ['m 0,0 20,19 60,0 l 20,-19', 'm 28,{} 4,{} 36,0 4,{}'.format(-mt, mt, -(mt))], 'perf' : ['M 0,0 28,0','M 100,0 72,0']}, \
|
||||||
|
24 : {'cut': ['M 100,0 90,18 30,11 20,0 0,0', 'm 92,{} -4,{} -36,0 -4,{}'.format(-mt, mt, -(mt))], 'perf' : ['M 100,0 92,0', 'M 20,0 48,0']}, \
|
||||||
|
18 : {'cut': ['M 100,0 90,16 40,9 35,0 0,0', 'm 92,{} -4,{} -26,0 -4,{}'.format(-mt, mt, -(mt))], 'perf' : ['M 100,0 92,0', 'M 35,0 58,0']}, \
|
||||||
|
6 : {'cut': ['M 100,0 98,10 88,9 84,2 86,2 86,0 0,0'], 'perf' : ['m 96,0 -6,0']},
|
||||||
|
0 : {'cut': ['m 0,0 100,0'], 'perf' : [] }}, simpletab, notab, notab]
|
||||||
|
return [tabStyle, slotStyle]
|
||||||
|
|
||||||
def get_connector(self, type, limitAngle):
|
def get_connector(self, type, limitAngle):
|
||||||
if(self.options.tabs == 1): # two tabs
|
if(self.options.tabs == 1): # two tabs
|
||||||
return(self.gen_tab(limitAngle/2))
|
return(self.gen_tab(limitAngle/2))
|
||||||
@ -84,9 +87,9 @@ class Polyhedra(inkex.EffectExtension):
|
|||||||
# otherwise, get stuff from the array of specially modified tab/slots
|
# otherwise, get stuff from the array of specially modified tab/slots
|
||||||
|
|
||||||
if(type == 'tab'):
|
if(type == 'tab'):
|
||||||
source = tabStyle
|
source = self.get_slot_tab_style()[0]
|
||||||
else:
|
else:
|
||||||
source = slotStyle
|
source = self.get_slot_tab_style()[1]
|
||||||
|
|
||||||
cuttable = source[self.options.tabs].keys()
|
cuttable = source[self.options.tabs].keys()
|
||||||
sorted(cuttable) # sorts in-place. Ugh.
|
sorted(cuttable) # sorts in-place. Ugh.
|
||||||
@ -132,6 +135,7 @@ class Polyhedra(inkex.EffectExtension):
|
|||||||
return({'cut' : [points_to_svgd(tab_cut)], 'perf' : [points_to_svgd(tab_perf)]})
|
return({'cut' : [points_to_svgd(tab_cut)], 'perf' : [points_to_svgd(tab_perf)]})
|
||||||
|
|
||||||
def effect(self):
|
def effect(self):
|
||||||
|
|
||||||
poly = self.options.poly
|
poly = self.options.poly
|
||||||
size = self.svg.unittouu(str(self.options.size) + self.options.unit)
|
size = self.svg.unittouu(str(self.options.size) + self.options.unit)
|
||||||
|
|
||||||
@ -151,8 +155,8 @@ class Polyhedra(inkex.EffectExtension):
|
|||||||
gsub = etree.SubElement(g, 'g', gsub_attribs)
|
gsub = etree.SubElement(g, 'g', gsub_attribs)
|
||||||
|
|
||||||
# Create SVG Path
|
# Create SVG Path
|
||||||
cutStyle = { 'stroke': '#0000FF', 'stroke-width': '1px', 'fill': 'none' }
|
cutStyle = { 'stroke': '#0000FF', 'stroke-width': self.svg.unittouu("1px"), 'fill': 'none' }
|
||||||
perfStyle = { 'stroke': '#FF0000', 'stroke-width': '1px', 'fill': 'none' }
|
perfStyle = { 'stroke': '#FF0000', 'stroke-width': self.svg.unittouu("1px"), 'fill': 'none' }
|
||||||
textStyle = {
|
textStyle = {
|
||||||
'font-size': str( size/4 ),
|
'font-size': str( size/4 ),
|
||||||
'font-family': 'arial',
|
'font-family': 'arial',
|
||||||
|
Reference in New Issue
Block a user