Added Gen Box from thierry7100
This commit is contained in:
parent
29b5a12af3
commit
3c4ca85a06
72
extensions/fablabchemnitz_gen_box.inx
Normal file
72
extensions/fablabchemnitz_gen_box.inx
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<_name>Box Maker - Generic Generator</_name>
|
||||
<id>fablabchemnitz.de.gen_box</id>
|
||||
<param name="Topic" type="notebook">
|
||||
<page name="dimensions" _gui-text="Box dimensions">
|
||||
<param name="unit" type="enum" _gui-text="Unit">
|
||||
<_item value="mm">mm</_item>
|
||||
<_item value="cm">cm</_item>
|
||||
<_item value="m">m</_item>
|
||||
<_item value="km">km</_item>
|
||||
<_item value="in">in</_item>
|
||||
<_item value="ft">ft</_item>
|
||||
<_item value="yd">yd</_item>
|
||||
<_item value="pt">pt</_item>
|
||||
<_item value="px">px</_item>
|
||||
<_item value="pc">pc</_item>
|
||||
</param>
|
||||
<_param name="name" type="description" appearance="header">External dimensions for the box</_param>
|
||||
<param name="x" type="float" min="10.0" max="1000.0" _gui-text="width">80.0</param>
|
||||
<param name="y" type="float" min="10.0" max="1000.0" _gui-text="depth">60.0</param>
|
||||
<param name="z" type="float" min="10.0" max="1000.0" _gui-text="height">40.0</param>
|
||||
<param name="thickness" type="float" min="1.0" max="10.0" _gui-text="thickness of material">3.0</param>
|
||||
<param name="burn" type="float" min="0.0" max="2.0" _gui-text="Burn factor">0.1</param>
|
||||
</page>
|
||||
<page name="corners" _gui-text="Round corners">
|
||||
<param name="StraigthCorners" type="boolean" _gui-text="Straight corners">true</param>
|
||||
<_param name="name" type="description">If not straight corners, radius of each corner</_param>
|
||||
<param name="back_left_radius" type="float" min="0.0" max="100.0" _gui-text="Back left radius">10.0</param>
|
||||
<param name="back_right_radius" type="float" min="0.0" max="100.0" _gui-text="Back right radius">10.0</param>
|
||||
<param name="front_left_radius" type="float" min="0.0" max="100.0" _gui-text="Front left radius">10.0</param>
|
||||
<param name="front_right_radius" type="float" min="0.0" max="100.0" _gui-text="Front right radius">10.0</param>
|
||||
</page>
|
||||
<page name="Lid" _gui-text="Lid style">
|
||||
<param name="lid_type" type="enum" _gui-text="Lid style">
|
||||
<_item value="Without">Without lid</_item>
|
||||
<_item value="Closed">Closed box</_item>
|
||||
<_item value="Simple">Simple top</_item>
|
||||
<_item value="Sliding">Sliding lid</_item>
|
||||
<_item value="WoodHinge">Integrated wood hinge</_item>
|
||||
<_item value="SteelHinge">Steel hinge</_item>
|
||||
<_item value="Coffin">Coffin</_item>
|
||||
</param>
|
||||
<_param name="name" type="description" appearance="header">Only used with real lid</_param>
|
||||
<param name="z_lid" type="float" min="15.0" max="1000.0" _gui-text="Lid height">20.0</param>
|
||||
<_param name="name" type="description" appearance="header">Only used with coffin lid</_param>
|
||||
<param name="z_dome_lid" type="float" min="15.0" max="1000.0" _gui-text="dome lid height">20.0</param>
|
||||
<param name="SkipFlexLines" type="boolean" _gui-text="Skip flex lines when possible">true</param>
|
||||
</page>
|
||||
<page name="Slots" _gui-text="Internal slots">
|
||||
<param name="n_slot_x" type="int" min="1" max="20" _gui-text="Number of columns">1</param>
|
||||
<param name="n_slot_y" type="int" min="1" max="20" _gui-text="Number of rows">1</param>
|
||||
</page>
|
||||
<page name="Joints" _gui-text="Joints">
|
||||
<param name="AutoSize" type="boolean" _gui-text="Finger size computed from box dimensions">true</param>
|
||||
<param name="x_joint" type="float" min="1.0" max="100.0" _gui-text="Finger size for joints in X direction">5.0</param>
|
||||
<param name="y_joint" type="float" min="1.0" max="100.0" _gui-text="Finger size for joints in Y direction">5.0</param>
|
||||
<param name="z_joint" type="float" min="1.0" max="100.0" _gui-text="Finger size for joints in Z direction">5.0</param>
|
||||
</page>
|
||||
</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu _name="FabLab Chemnitz">
|
||||
<submenu _name="Finger-jointed/Tabbed Boxes" />
|
||||
</submenu>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command reldir="extensions" interpreter="python">fablabchemnitz_gen_box.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
3057
extensions/fablabchemnitz_gen_box.py
Normal file
3057
extensions/fablabchemnitz_gen_box.py
Normal file
File diff suppressed because it is too large
Load Diff
171
extensions/fablabchemnitz_inkscape_path.py
Normal file
171
extensions/fablabchemnitz_inkscape_path.py
Normal file
@ -0,0 +1,171 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# We will use the inkex module with the predefined Effect base class.
|
||||
import inkex
|
||||
import math
|
||||
from lxml import etree
|
||||
|
||||
|
||||
objStyle = str(inkex.Style({'stroke': '#000000',
|
||||
'stroke-width': 0.1,
|
||||
'fill': 'none'
|
||||
}))
|
||||
|
||||
class th_inkscape_path:
|
||||
def __init__(self, Offset, group, Label=None, Style = None):
|
||||
self.offsetX = Offset[0]
|
||||
self.offsetY = Offset[1]
|
||||
self.Path = ''
|
||||
self.group = group
|
||||
self.Label = Label
|
||||
if Style:
|
||||
self.Style = Style
|
||||
else:
|
||||
self.Style = objStyle
|
||||
self.xmin = -self.offsetX
|
||||
self.xmax = -self.offsetX
|
||||
self.ymin = -self.offsetY
|
||||
self.ymax = -self.offsetY
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
|
||||
def MoveTo(self, x, y):
|
||||
#Return string 'M X Y' where X and Y are updated values from parameters
|
||||
self.Path += ' M ' + str(round(x-self.offsetX, 3)) + ',' + str(round(y-self.offsetY, 3))
|
||||
self.x = x - self.offsetX
|
||||
self.y = y - self.offsetY
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
def LineTo(self, x, y):
|
||||
#Return string 'L X Y' where X and Y are updated values from parameters
|
||||
self.Path += ' L ' + str(round(x-self.offsetX, 3)) + ',' + str(round(y-self.offsetY, 3))
|
||||
self.x = x - self.offsetX
|
||||
self.y = y - self.offsetY
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
|
||||
def LineToRel(self, x, y):
|
||||
#Return string 'L X Y' where X and Y are updated values from parameters
|
||||
self.Path += ' l ' + str(round(x, 3)) + ',' + str(round(y, 3))
|
||||
self.x += x
|
||||
self.y += y
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
def LineToHRel(self, x):
|
||||
#Return string 'h X' where X are updated values from parameters
|
||||
self.Path += ' h ' + str(round(x, 3))
|
||||
self.x += x
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
|
||||
|
||||
def LineToVRel(self, y):
|
||||
#Return string 'v Y' where X and Y are updated values from parameters
|
||||
self.Path += ' v ' + str(round(y, 3))
|
||||
self.y += y
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
def Line(self, x1, y1, x2, y2):
|
||||
self.x = x1 - self.offsetX
|
||||
self.y = y1 - self.offsetY
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
#Return string M X1 Y1 L X2 Y2
|
||||
self.Path += ' M ' + str(round(x1-self.offsetX, 3)) + ',' + str(round(y1-self.offsetY, 3)) + ' L ' + str(round(x2-self.offsetX, 3)) + ',' + str(round(y2-self.offsetY, 3))
|
||||
self.x = x2 - self.offsetX
|
||||
self.y = y2 - self.offsetY
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
def LineRel(self, x1, y1, x2, y2):
|
||||
self.x += x1
|
||||
self.y += y1
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
#Return string m X1 Y1 l X2 Y2
|
||||
self.Path += ' m ' + str(round(x1, 3)) + ',' + str(round(y1, 3)) + ' l ' + str(round(x2, 3)) + ',' + str(round(y2, 3))
|
||||
self.x += x2
|
||||
self.y += y2
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
def Bezier(self, xc1, yc1, xc2, yc2, x, y):
|
||||
#Return string C XC1 YC1 XC2 YC2 X Y
|
||||
self.Path += ' C ' + str(round(xc1-self.offsetX, 3)) + ',' + str(round(yc1-self.offsetY, 3)) + ' ' + str(round(xc2-self.offsetX, 3)) + ',' + str(round(yc2-self.offsetY, 3))+ ' ' + str(round(x-self.offsetX, 3)) + ',' + str(round(y-self.offsetY, 3))
|
||||
self.x = x - self.offsetX
|
||||
self.y = y - self.offsetY
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
def BezierRel(self, xc1, yc1, xc2, yc2, x, y):
|
||||
#Return string c XC1 YC1 XC2 YC2 X Y
|
||||
self.Path += ' c ' + str(round(xc1, 3)) + ',' + str(round(yc1, 3)) + ' ' + str(round(xc2, 3)) + ',' + str(round(yc2, 3))+ ' ' + str(round(x, 3)) + ',' + str(round(y, 3))
|
||||
self.x += x
|
||||
self.y += y
|
||||
self.xmin= min(self.x, self.xmin)
|
||||
self.xmax= max(self.x, self.xmax)
|
||||
self.ymin= min(self.y, self.ymin)
|
||||
self.ymax= max(self.y, self.ymax)
|
||||
|
||||
|
||||
def drawQuarterCircle(self, xc, yc, radius, quarter):
|
||||
'''
|
||||
Draw a quarter of circle with a single bezier path
|
||||
xc, yc give the center of the circle, radius its radius
|
||||
quarter = 0 : upper left, 1: upper right, 2: lower right, 3: lower left
|
||||
Starting point is the last point of the path
|
||||
'''
|
||||
if quarter == 0:
|
||||
self.Bezier(xc-radius, yc - radius*0.551916, xc - radius*0.551916, yc-radius, xc, yc-radius) # upper left quarter
|
||||
elif quarter == 1:
|
||||
self.Bezier(xc+radius*0.551916, yc - radius, xc + radius, yc-radius*0.551916, xc+radius, yc) # upper right quarter
|
||||
elif quarter == 2:
|
||||
self.Bezier(xc+radius, yc + radius*0.551916, xc + radius*0.551916, yc+radius, xc, yc+radius) # lower right quarter
|
||||
elif quarter == 3:
|
||||
self.Bezier(xc+radius*-0.551916, yc + radius, xc - radius, yc+radius*0.551916, xc-radius, yc) # lower left quarter
|
||||
|
||||
|
||||
def drawCircle(self, xc, yc, radius):
|
||||
#Draw a circle, with 4 Bezier paths
|
||||
self.MoveTo(xc+radius, yc) #R, 0
|
||||
self.Bezier(xc+radius, yc + radius*0.551916, xc + radius*0.551916, yc+radius, xc, yc+radius) #1er quarter, lower right
|
||||
self.Bezier(xc+radius*-0.551916, yc + radius, xc - radius, yc+radius*0.551916, xc-radius, yc) #2nd quarter, lower left
|
||||
self.Bezier(xc-radius, yc - radius*0.551916, xc - radius*0.551916, yc-radius, xc, yc-radius) #3rd quarter, upper left
|
||||
self.Bezier(xc+radius*0.551916, yc - radius, xc + radius, yc-radius*0.551916, xc+radius, yc) #4th quarter, upper right
|
||||
|
||||
def Close(self):
|
||||
self.Path += ' z'
|
||||
|
||||
def GenPath(self):
|
||||
if self.Label:
|
||||
line_attribs = {'style': self.Style, 'id' : self.Label, 'd': self.Path}
|
||||
else:
|
||||
line_attribs = {'style': self.Style, 'd': self.Path}
|
||||
etree.SubElement(self.group, inkex.addNS('path', 'svg'), line_attribs)
|
||||
|
||||
def GetBoundingBox(self):
|
||||
'''
|
||||
return a tuple giving MinPos, MaxPos and Size (6 elements)
|
||||
'''
|
||||
return(self.xmin, self.ymin, self.xmax, self.ymax, self.xmax - self.xmin, self.ymax - self.ymin)
|
Reference in New Issue
Block a user