Fix typos and docstrings

This commit is contained in:
Rotzbua 2023-01-02 00:32:42 +01:00 committed by Florian Festi
parent d2d2d15de3
commit 5fae61bd0d
48 changed files with 165 additions and 235 deletions

View File

@ -46,16 +46,15 @@ def dist(dx, dy):
Return distance Return distance
:param dx: delta x :param dx: delta x
:param dy: delat y :param dy: delay y
""" """
return (dx * dx + dy * dy) ** 0.5 return (dx * dx + dy * dy) ** 0.5
def restore(func): def restore(func):
""" """
Wrapper: Restore coordiantes after function Wrapper: Restore coordinates after function
:param func: function to wrap :param func: function to wrap
""" """
@wraps(func) @wraps(func)
@ -73,7 +72,6 @@ def holeCol(func):
Wrapper: color holes differently Wrapper: color holes differently
:param func: function to wrap :param func: function to wrap
""" """
@wraps(func) @wraps(func)
@ -150,7 +148,6 @@ def argparseSections(s):
Parse sections parameter Parse sections parameter
:param s: string to parse :param s: string to parse
""" """
result = [] result = []
@ -280,7 +277,7 @@ Values:
############################################################################## ##############################################################################
class Boxes: class Boxes:
"""Main class -- Generator should sub class this """ """Main class -- Generator should subclass this """
webinterface = True webinterface = True
ui_group = "Misc" ui_group = "Misc"
@ -405,8 +402,8 @@ class Boxes:
""" """
Add commonly used arguments Add commonly used arguments
:param \*l: parameter names :param l: parameter names
:param \*\*kw: parameters with new default values :param kw: parameters with new default values
Supported parameters are Supported parameters are
@ -509,7 +506,6 @@ class Boxes:
Parse command line parameters Parse command line parameters
:param args: (Default value = None) parameters, None for using sys.argv :param args: (Default value = None) parameters, None for using sys.argv
""" """
if args is None: if args is None:
args = sys.argv[1:] args = sys.argv[1:]
@ -543,7 +539,6 @@ class Boxes:
:param part: Callable :param part: Callable
:param name: (Default value = None) attribute name (__name__ as default) :param name: (Default value = None) attribute name (__name__ as default)
""" """
if name is None: if name is None:
name = part.__class__.__name__ name = part.__class__.__name__
@ -559,7 +554,7 @@ class Boxes:
self.addPart(part) self.addPart(part)
def _buildObjects(self): def _buildObjects(self):
"""Add default edges and parts """ """Add default edges and parts"""
self.edges = {} self.edges = {}
self.addPart(edges.Edge(self, None)) self.addPart(edges.Edge(self, None))
self.addPart(edges.OutSetEdge(self, None)) self.addPart(edges.OutSetEdge(self, None))
@ -652,9 +647,10 @@ class Boxes:
return l - walls return l - walls
def render(self): def render(self):
"""Implement this method in your sub class. """Implement this method in your subclass.
You will typically need to call .parseArgs() before calling this one""" You will typically need to call .parseArgs() before calling this one
"""
self.open() self.open()
# Change settings and create new Edges and part classes here # Change settings and create new Edges and part classes here
raise NotImplementedError raise NotImplementedError
@ -667,7 +663,6 @@ class Boxes:
:param number: number of the callback :param number: number of the callback
:param x: (Default value = 0.0) x position to be call on :param x: (Default value = 0.0) x position to be call on
:param y: (Default value = None) y position to be called on (default does burn correction) :param y: (Default value = None) y position to be called on (default does burn correction)
""" """
if y is None: if y is None:
y = self.burn y = self.burn
@ -694,7 +689,6 @@ class Boxes:
:param param: list or item :param param: list or item
:param idx: index in list :param idx: index in list
""" """
if isinstance(param, list): if isinstance(param, list):
if len(param) > idx: if len(param) > idx:
@ -740,7 +734,6 @@ class Boxes:
:param degrees: angle :param degrees: angle
:param radius: (Default value = 0) :param radius: (Default value = 0)
""" """
try: try:
@ -798,7 +791,6 @@ class Boxes:
""" """
Simple line Simple line
:param length: length in mm :param length: length in mm
""" """
self.ctx.move_to(0, 0) self.ctx.move_to(0, 0)
if tabs and self.tabs: if tabs and self.tabs:
@ -823,7 +815,7 @@ class Boxes:
def step(self, out): def step(self, out):
""" """
Create a parallel step prependicular to the current direction Create a parallel step perpendicular to the current direction
Positive values move to the outside of the part Positive values move to the outside of the part
""" """
if out > 1E-5: if out > 1E-5:
@ -844,7 +836,6 @@ class Boxes:
:param y2: :param y2:
:param x3: :param x3:
:param y3: :param y3:
""" """
self.ctx.curve_to(x1, y1, x2, y2, x3, y3) self.ctx.curve_to(x1, y1, x2, y2, x3, y3)
dx = x3 - x2 dx = x3 - x2
@ -856,7 +847,7 @@ class Boxes:
""" """
Draw multiple connected lines Draw multiple connected lines
:param \*args: Alternating length in mm and angle in degrees. :param args: Alternating length in mm and angle in degrees.
lengths may be a tuple (length, #tabs) lengths may be a tuple (length, #tabs)
angles may be tuple (angle, radius) angles may be tuple (angle, radius)
@ -878,8 +869,7 @@ class Boxes:
Draw an edge with slot for a bed bolt Draw an edge with slot for a bed bolt
:param length: length of the edge in mm :param length: length of the edge in mm
:param bedBoltSettings: (Default value = None) Dimmensions of the slot :param bedBoltSettings: (Default value = None) Dimensions of the slot
""" """
d, d_nut, h_nut, l, l1 = bedBoltSettings or self.bedBoltSettings d, d_nut, h_nut, l, l1 = bedBoltSettings or self.bedBoltSettings
self.edge((length - d) / 2.0, tabs=tabs//2) self.edge((length - d) / 2.0, tabs=tabs//2)
@ -953,7 +943,7 @@ class Boxes:
"""Create regular polygon as a wall """Create regular polygon as a wall
:param corners: number of corners of the polygon :param corners: number of corners of the polygon
:param radius: distance center to one of the corners :param r: radius distance center to one of the corners
:param h: distance center to one of the sides (height of sector) :param h: distance center to one of the sides (height of sector)
:param side: length of one side :param side: length of one side
:param edges: (Default value = "e", may be string/list of length corners) :param edges: (Default value = "e", may be string/list of length corners)
@ -1002,11 +992,10 @@ class Boxes:
self.move(tw, th, move) self.move(tw, th, move)
def grip(self, length, depth): def grip(self, length, depth):
"""Corrugated edge useful as an gipping area """Corrugated edge useful as a gipping area
:param length: length :param length: length
:param depth: depth of the grooves :param depth: depth of the grooves
""" """
grooves = max(int(length // (depth * 2.0)) + 1, 1) grooves = max(int(length // (depth * 2.0)) + 1, 1)
depth = length / grooves / 4.0 depth = length / grooves / 4.0
@ -1017,9 +1006,7 @@ class Boxes:
def _latchHole(self, length): def _latchHole(self, length):
""" """
:param length: :param length:
""" """
self.edge(1.1 * self.thickness) self.edge(1.1 * self.thickness)
self.corner(-90) self.corner(-90)
@ -1029,9 +1016,7 @@ class Boxes:
def _latchGrip(self, length): def _latchGrip(self, length):
""" """
:param length: :param length:
""" """
self.corner(90, self.thickness / 4.0) self.corner(90, self.thickness / 4.0)
self.grip(length / 2.0 - self.thickness / 2.0 - 0.2 * self.thickness, self.thickness / 2.0) self.grip(length / 2.0 - self.thickness / 2.0 - 0.2 * self.thickness, self.thickness / 2.0)
@ -1043,7 +1028,6 @@ class Boxes:
:param length: length in mm :param length: length in mm
:param positive: (Default value = True) False: Door side; True: Box side :param positive: (Default value = True) False: Door side; True: Box side
:param reverse: (Default value = False) True when running away from the latch :param reverse: (Default value = False) True when running away from the latch
""" """
if positive: if positive:
if reverse: if reverse:
@ -1075,7 +1059,6 @@ class Boxes:
:param h: height in mm :param h: height in mm
:param hl: height if th grip hole :param hl: height if th grip hole
:param r: (Default value = 30) radius of the corners :param r: (Default value = 30) radius of the corners
""" """
d = (x - hl - 2 * r) / 2.0 d = (x - hl - 2 * r) / 2.0
@ -1108,7 +1091,6 @@ class Boxes:
:param x: :param x:
:param y: (Default value = 0.0) :param y: (Default value = 0.0)
:param degrees: (Default value = 0) :param degrees: (Default value = 0)
""" """
self.ctx.move_to(0, 0) self.ctx.move_to(0, 0)
self.ctx.translate(x, y) self.ctx.translate(x, y)
@ -1137,7 +1119,6 @@ class Boxes:
Set coordinate system to current position (end point) Set coordinate system to current position (end point)
:param angle: (Default value = 0) heading :param angle: (Default value = 0) heading
""" """
self.ctx.translate(*self.ctx.get_current_point()) self.ctx.translate(*self.ctx.get_current_point())
self.ctx.rotate(angle) self.ctx.rotate(angle)
@ -1147,16 +1128,15 @@ class Boxes:
where can be combinations of "up" or "down", "left" or "right", "only", where can be combinations of "up" or "down", "left" or "right", "only",
"mirror" and "rotated" "mirror" and "rotated"
when "only" is included the move is only done when before is True when "only" is included the move is only done when before is True
"mirror" will flip the part along the y axis "mirror" will flip the part along the y-axis
"rotated" draws the parts rotated 90 counter clockwise "rotated" draws the parts rotated 90 counter clockwise
The function returns whether actual drawing of the part The function returns whether actual drawing of the part
should be ommited. should be omitted.
:param x: width of part :param x: width of part
:param y: height of part :param y: height of part
:param where: which direction to move :param where: which direction to move
:param before: (Default value = False) called before or after part being drawn :param before: (Default value = False) called before or after part being drawn
""" """
if not where: if not where:
where = "" where = ""
@ -1221,9 +1201,8 @@ class Boxes:
Draw a round disc Draw a round disc
:param x: position :param x: position
:param y: postion :param y: position
:param r: radius :param r: radius
""" """
r += self.burn r += self.burn
self.moveTo(x + r, y) self.moveTo(x + r, y)
@ -1242,11 +1221,10 @@ class Boxes:
Draw a hole in shape of an n-edged regular polygon Draw a hole in shape of an n-edged regular polygon
:param x: position :param x: position
:param y: postion :param y: position
:param r: radius :param r: radius
:param n: number of edges :param n: number of edges
:param a: rotation angle :param a: rotation angle
""" """
if not r: if not r:
@ -1287,9 +1265,8 @@ class Boxes:
Draw a round hole Draw a round hole
:param x: position :param x: position
:param y: postion :param y: position
:param r: radius :param r: radius
""" """
if not r: if not r:
@ -1313,7 +1290,6 @@ class Boxes:
:param r: (Default value = 0) radius of the corners :param r: (Default value = 0) radius of the corners
:param center_x: (Default value = True) if True, x position is the center, else the start :param center_x: (Default value = True) if True, x position is the center, else the start
:param center_y: (Default value = True) if True, y position is the center, else the start :param center_y: (Default value = True) if True, y position is the center, else the start
""" """
r = min(r, dx/2., dy/2.) r = min(r, dx/2., dy/2.)
x_start = x if center_x else x + dx / 2.0 x_start = x if center_x else x + dx / 2.0
@ -1336,8 +1312,7 @@ class Boxes:
:param d: diameter :param d: diameter
:param w: width measured against flat side in mm :param w: width measured against flat side in mm
:param rel_w: width in percent :param rel_w: width in percent
:param angle: orentation (rotation) of the flat side :param angle: orientation (rotation) of the flat side
""" """
if r is None: if r is None:
@ -1370,7 +1345,6 @@ class Boxes:
:param w: width measured against flat side in mm :param w: width measured against flat side in mm
:param rel_w: width in percent :param rel_w: width in percent
:param angle: orientation (rotation) of the flat sides :param angle: orientation (rotation) of the flat sides
""" """
if r is None: if r is None:
@ -1401,11 +1375,10 @@ class Boxes:
Draw a pear shaped mounting hole for sliding over a screw head. Total height = 1.5* d_shaft + d_head Draw a pear shaped mounting hole for sliding over a screw head. Total height = 1.5* d_shaft + d_head
:param x: position :param x: position
:param y: postion :param y: position
:param d_shaft: diameter of the screw shaft :param d_shaft: diameter of the screw shaft
:param d_head: diameter of the screw head :param d_head: diameter of the screw head
:param angle: rotation angle of the hole :param angle: rotation angle of the hole
""" """
if d_shaft < (2 * self.burn): if d_shaft < (2 * self.burn):
@ -1438,7 +1411,6 @@ class Boxes:
:param y: (Default value = 0) :param y: (Default value = 0)
:param angle: (Default value = 0) :param angle: (Default value = 0)
:param align: (Default value = "") string with combinations of (top|middle|bottom) and (left|center|right) separated by a space :param align: (Default value = "") string with combinations of (top|middle|bottom) and (left|center|right) separated by a space
""" """
self.moveTo(x, y, angle) self.moveTo(x, y, angle)
text = text.split("\n") text = text.split("\n")
@ -1537,7 +1509,7 @@ class Boxes:
:param x: (Default value = 0) :param x: (Default value = 0)
:param y: (Default value = 0) :param y: (Default value = 0)
:param angle: (Default value = 0) :param angle: (Default value = 0)
:param screwholes:
""" """
width, flange, holedistance, diameter = self.nema_sizes[size] width, flange, holedistance, diameter = self.nema_sizes[size]
if screwholes: if screwholes:
@ -1558,7 +1530,7 @@ class Boxes:
draw border polygon (for debugging only) draw border polygon (for debugging only)
:param border: array with coordinate [(x0,y0), (x1,y1),...] of the border polygon :param border: array with coordinate [(x0,y0), (x1,y1),...] of the border polygon
:param color:
""" """
self.set_source_color(color) self.set_source_color(color)
self.ctx.save() self.ctx.save()
@ -1591,7 +1563,6 @@ class Boxes:
:param style: defines hole style - currently one of "round", "triangle", "square", "hexagon" or "octagon" :param style: defines hole style - currently one of "round", "triangle", "square", "hexagon" or "octagon"
:param bar_length: maximum bar length :param bar_length: maximum bar length
:param max_random: maximum number of random holes :param max_random: maximum number of random holes
""" """
if pattern not in ["random", "hex", "square", "hbar", "vbar"]: if pattern not in ["random", "hex", "square", "hbar", "vbar"]:
return return
@ -1769,7 +1740,7 @@ class Boxes:
# and process line # and process line
while not xw > x_end: while not xw > x_end:
# are we in inner polygone already? # are we in inner polygon already?
if (len(inner_line_split) > inner_line_index and if (len(inner_line_split) > inner_line_index and
xw > inner_line_split.geoms[inner_line_index].bounds[0]): xw > inner_line_split.geoms[inner_line_index].bounds[0]):
# place inner, full size polygons # place inner, full size polygons
@ -1828,7 +1799,7 @@ class Boxes:
segment_max = 0 segment_max = 0
segment_toggle ^= 1 segment_toggle ^= 1
# create line from left to right and cut according to shrinked polygon # create line from left to right and cut according to shrunk polygon
line_complete = LineString([(min_x - 1, y), (max_x + 1, y)]) line_complete = LineString([(min_x - 1, y), (max_x + 1, y)])
line_split = split(line_complete, cutPoly) line_split = split(line_complete, cutPoly)
@ -1927,8 +1898,6 @@ class Boxes:
:param settings: (Default value = None) :param settings: (Default value = None)
:param skip: (Default value = None) function to check if hole should be present :param skip: (Default value = None) function to check if hole should be present
gets x, y, r, b, posx, posy gets x, y, r, b, posx, posy
""" """
if settings is None: if settings is None:
@ -1966,7 +1935,6 @@ class Boxes:
:param d: diameter of the circle :param d: diameter of the circle
:param settings: (Default value = None) :param settings: (Default value = None)
""" """
d2 = d / 2.0 d2 = d / 2.0
self.hexHolesRectangle(d, d, settings=settings, skip=self.__skipcircle) self.hexHolesRectangle(d, d, settings=settings, skip=self.__skipcircle)
@ -1979,19 +1947,16 @@ class Boxes:
:param y: height :param y: height
:param rc: radius of the corners :param rc: radius of the corners
:param settings: (Default value = None) :param settings: (Default value = None)
""" """
def skip(x, y, r, b, posx, posy): def skip(x, y, r, b, posx, posy):
""" """
:param x: :param x:
:param y: :param y:
:param r: :param r:
:param b: :param b:
:param posx: :param posx:
:param posy: :param posy:
""" """
posx = abs(posx - (x / 2.0)) posx = abs(posx - (x / 2.0))
posy = abs(posy - (y / 2.0)) posy = abs(posy - (y / 2.0))
@ -2012,7 +1977,6 @@ class Boxes:
:param h: height :param h: height
:param settings: (Default value = None) :param settings: (Default value = None)
:param grow: (Default value = None) :param grow: (Default value = None)
""" """
if settings is None: if settings is None:
settings = self.hexHolesSettings settings = self.hexHolesSettings
@ -2027,7 +1991,7 @@ class Boxes:
if grow == 'space ': if grow == 'space ':
b += leftover / (cy - 1) / 2 b += leftover / (cy - 1) / 2
# recalulate with adjusted values # recalculate with adjusted values
w = r + b / 2.0 w = r + b / 2.0
dist = w * math.cos(math.pi / 6.0) dist = w * math.cos(math.pi / 6.0)
@ -2087,7 +2051,7 @@ class Boxes:
:param x: x position of the center :param x: x position of the center
:param y: y position of the center :param y: y position of the center
:param angle: angle in which the rectangle is placed :param angle: angle in which the rectangle is placed
:param outside: meassure size from the outside of the walls - not the inside :param outside: measure size from the outside of the walls - not the inside
""" """
self.moveTo(x, y, angle) self.moveTo(x, y, angle)
d = 0.5*self.thickness d = 0.5*self.thickness
@ -2128,6 +2092,7 @@ class Boxes:
:param x: width :param x: width
:param y: height :param y: height
:param r: radius of the corners :param r: radius of the corners
:param edge:
:param callback: (Default value = None) :param callback: (Default value = None)
:param holesMargin: (Default value = None) set to get hex holes :param holesMargin: (Default value = None) set to get hex holes
:param holesSettings: (Default value = None) :param holesSettings: (Default value = None)
@ -2136,7 +2101,6 @@ class Boxes:
:param wallpieces: (Default value = 1) # of separate surrounding walls :param wallpieces: (Default value = 1) # of separate surrounding walls
:param extend_corners: (Default value = True) have corners outset with the edges :param extend_corners: (Default value = True) have corners outset with the edges
:param move: (Default value = None) :param move: (Default value = None)
""" """
corner_holes = True corner_holes = True
@ -2245,7 +2209,7 @@ class Boxes:
callback=None, callback=None,
move=None): move=None):
""" """
Wall(s) with flex fiting around a roundedPlate() Wall(s) with flex filing around a roundedPlate()
For the callbacks the sides are counted depending on pieces For the callbacks the sides are counted depending on pieces
@ -2260,7 +2224,6 @@ class Boxes:
:param pieces: (Default value = 1) number of separate pieces :param pieces: (Default value = 1) number of separate pieces
:param callback: (Default value = None) :param callback: (Default value = None)
:param move: (Default value = None) :param move: (Default value = None)
""" """
t = self.thickness t = self.thickness
c4 = (r + self.burn) * math.pi * 0.5 # circumference of quarter circle c4 = (r + self.burn) * math.pi * 0.5 # circumference of quarter circle
@ -2364,7 +2327,6 @@ class Boxes:
:param callback: (Default value = None) :param callback: (Default value = None)
:param move: (Default value = None) :param move: (Default value = None)
:param label: rendered to identify parts, it is not ment to be cut or etched (Default value = "") :param label: rendered to identify parts, it is not ment to be cut or etched (Default value = "")
""" """
if len(edges) != 4: if len(edges) != 4:
raise ValueError("four edges required") raise ValueError("four edges required")
@ -2472,7 +2434,7 @@ class Boxes:
:param x: width :param x: width
:param y: height :param y: height
:param edges: (Default value = "eee") bottom, right[, diagonal] :param edges: (Default value = "eee") bottom, right[, diagonal]
:param r: radius towards the hypothenuse :param r: radius towards the hypotenuse
:param num: (Default value = 1) number of triangles :param num: (Default value = 1) number of triangles
:param bedBolts: (Default value = None) :param bedBolts: (Default value = None)
:param bedBoltSettings: (Default value = None) :param bedBoltSettings: (Default value = None)
@ -2702,12 +2664,11 @@ class Boxes:
Polygon wall for all kind of multi-edged objects Polygon wall for all kind of multi-edged objects
:param borders: array of distance and angles to draw :param borders: array of distance and angles to draw
:param edge: (Default value = "f") Edges to apply. If the array of borders contains more segments that edges, the edge will wrap. Only edge types without start and end width suppported for now. :param edge: (Default value = "f") Edges to apply. If the array of borders contains more segments that edges, the edge will wrap. Only edge types without start and end width supported for now.
:param turtle: (Default value = False) :param turtle: (Default value = False)
:param callback: (Default value = None) :param callback: (Default value = None)
:param move: (Default value = None) :param move: (Default value = None)
:param label: rendered to identify parts, it is not ment to be cut or etched (Default value = "") :param label: rendered to identify parts, it is not ment to be cut or etched (Default value = "")
""" """
try: try:
edges = [self.edges.get(e, e) for e in edge] edges = [self.edges.get(e, e) for e in edge]
@ -2836,10 +2797,10 @@ class Boxes:
:param n: number of parts :param n: number of parts
:param width: number of parts in a row (0 for same as n) :param width: number of parts in a row (0 for same as n)
:param move: (Default value = None) :param move: (Default value = "")
:param part: callable that draws a part and knows move param :param part: callable that draws a part and knows move param
:param \*l: params for part :param l: params for part
:param \*\*kw: keyword params for part :param kw: keyword params for part
""" """
if n <= 0: if n <= 0:
return return

View File

@ -9,7 +9,7 @@ from boxes.extents import Extents
EPS = 1e-4 EPS = 1e-4
PADDING = 10 PADDING = 10
RANDOMIZE_COLORS = False # enable to ease check for continuity of pathes RANDOMIZE_COLORS = False # enable to ease check for continuity of paths
def points_equal(x1, y1, x2, y2): def points_equal(x1, y1, x2, y2):
@ -989,7 +989,7 @@ def line_intersection(line1, line2):
div = det(xdiff, ydiff) div = det(xdiff, ydiff)
if div == 0: if div == 0:
# todo: deal with paralel line intersection / overlay # todo: deal with parallel line intersection / overlay
return False, None, None return False, None, None
d = (det(*line1), det(*line2)) d = (det(*line1), det(*line2))

View File

@ -29,7 +29,6 @@ def argparseSections(s):
Parse sections parameter Parse sections parameter
:param s: string to parse :param s: string to parse
""" """
result = [] result = []
@ -78,14 +77,12 @@ class BoltPolicy(object):
Distributes (bed) bolts on a number of segments Distributes (bed) bolts on a number of segments
(fingers of a finger joint) (fingers of a finger joint)
""" """
def drawbolt(self, pos): def drawbolt(self, pos):
"""Add a bolt to this segment? """Add a bolt to this segment?
:param pos: number of the finger :param pos: number of the finger
""" """
return False return False
@ -93,7 +90,6 @@ class BoltPolicy(object):
"""Return next smaller, possible number of fingers """Return next smaller, possible number of fingers
:param numfingers: number of fingers to aim for :param numfingers: number of fingers to aim for
""" """
return numfingers return numfingers
@ -102,7 +98,6 @@ class BoltPolicy(object):
Return same or next smaller even number Return same or next smaller even number
:param numFingers: :param numFingers:
""" """
return (numFingers // 2) * 2 return (numFingers // 2) * 2
@ -111,7 +106,6 @@ class BoltPolicy(object):
Return same or next smaller odd number Return same or next smaller odd number
:param numFingers: :param numFingers:
""" """
if numFingers % 2: if numFingers % 2:
return numFingers return numFingers
@ -138,7 +132,6 @@ class Bolts(BoltPolicy):
Return if this finger needs a bolt Return if this finger needs a bolt
:param pos: number of this finger :param pos: number of this finger
""" """
if pos > self.fingers // 2: if pos > self.fingers // 2:
pos = self.fingers - pos pos = self.fingers - pos
@ -165,7 +158,7 @@ class Settings(object):
of the material used. of the material used.
Overload the absolute_params and relative_params class attributes with Overload the absolute_params and relative_params class attributes with
the suported keys and default values. The values are available via the supported keys and default values. The values are available via
attribute access. attribute access.
""" """
absolute_params: Dict[str, Any] = {} # TODO find better typing. absolute_params: Dict[str, Any] = {} # TODO find better typing.
@ -242,7 +235,6 @@ class Settings(object):
:param boxes: Boxes object :param boxes: Boxes object
:param chars: sequence of chars to be used by Edge objects :param chars: sequence of chars to be used by Edge objects
:param add: add the resulting Edge objects to the Boxes object's edges :param add: add the resulting Edge objects to the Boxes object's edges
""" """
edges = [] edges = []
return self._edgeObjects(edges, boxes, chars, add) return self._edgeObjects(edges, boxes, chars, add)
@ -265,9 +257,8 @@ class Settings(object):
Set values Set values
:param thickness: thickness of the material used :param thickness: thickness of the material used
:param relative: (Default value = True) Do scale by thickness :param relative: Do scale by thickness (Default value = True)
:param \*\*kw: parameters to set :param kw: parameters to set
""" """
factor = 1.0 factor = 1.0
if relative: if relative:
@ -349,7 +340,7 @@ class Edge(BaseEdge):
def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw): def __call__(self, length, bedBolts=None, bedBoltSettings=None, **kw):
"""Draw edge of length mm""" """Draw edge of length mm"""
if bedBolts: if bedBolts:
# distribute the bolts aequidistantly # distribute the bolts equidistantly
interval_length = length / bedBolts.bolts interval_length = length / bedBolts.bolts
if self.positive: if self.positive:
d = (bedBoltSettings or self.bedBoltSettings)[0] d = (bedBoltSettings or self.bedBoltSettings)[0]
@ -768,7 +759,7 @@ class CompoundEdge(BaseEdge):
############################################################################# #############################################################################
class Slot(BaseEdge): class Slot(BaseEdge):
"""Edge with an slot to slid another pice through """ """Edge with a slot to slide another piece through """
description = "Slot" description = "Slot"
@ -1043,7 +1034,6 @@ class FingerHoles(FingerJointBase):
:param angle: (Default value = 90) :param angle: (Default value = 90)
:param bedBolts: (Default value = None) :param bedBolts: (Default value = None)
:param bedBoltSettings: (Default value = None) :param bedBoltSettings: (Default value = None)
""" """
with self.boxes.saved_context(): with self.boxes.saved_context():
self.boxes.moveTo(x, y, angle) self.boxes.moveTo(x, y, angle)
@ -1638,8 +1628,7 @@ class ChestHinge(BaseEdge):
return self.settings.pin_height+self.settings.hinge_strength return self.settings.pin_height+self.settings.hinge_strength
class ChestHingeTop(ChestHinge): class ChestHingeTop(ChestHinge):
"""Edge above a chest hinge"""
"Edge above a chest hinge"
char = "p" char = "p"
@ -1921,7 +1910,6 @@ class CabinetHingeEdge(BaseEdge):
############################################################################# #############################################################################
class LidSettings(FingerJointSettings): class LidSettings(FingerJointSettings):
"""Settings for Slide-on Lids """Settings for Slide-on Lids
Note that edge_width below also determines how much the sides extend above the lid. Note that edge_width below also determines how much the sides extend above the lid.
@ -1933,8 +1921,6 @@ Values:
* second_pin : True : additional pin for better positioning * second_pin : True : additional pin for better positioning
* spring : "both" : position(s) of the extra locking springs in the lid * spring : "both" : position(s) of the extra locking springs in the lid
* hole_width : 0 : width of the "finger hole" in mm * hole_width : 0 : width of the "finger hole" in mm
""" """
__doc__ += FingerJointSettings.__doc__ or "" __doc__ += FingerJointSettings.__doc__ or ""
@ -2342,7 +2328,7 @@ Values:
* absolute * absolute
* stretch : 1.05 : Hint of how much the flex part should be shortend * stretch : 1.05 : Hint of how much the flex part should be shortened
* relative (in multiples of thickness) * relative (in multiples of thickness)
@ -2422,7 +2408,6 @@ class FlexEdge(BaseEdge):
self.ctx.translate(*self.ctx.get_current_point()) self.ctx.translate(*self.ctx.get_current_point())
class GearSettings(Settings): class GearSettings(Settings):
"""Settings for rack (and pinion) edge """Settings for rack (and pinion) edge
Values: Values:
* absolute_params * absolute_params
@ -2469,7 +2454,6 @@ class RackEdge(BaseEdge):
return self.settings.dimension * 1.1 return self.settings.dimension * 1.1
class RoundedTriangleEdgeSettings(Settings): class RoundedTriangleEdgeSettings(Settings):
"""Settings for RoundedTriangleEdge """Settings for RoundedTriangleEdge
Values: Values:
@ -2550,7 +2534,6 @@ class RoundedTriangleFingerHolesEdge(RoundedTriangleEdge):
class HandleEdgeSettings(Settings): class HandleEdgeSettings(Settings):
"""Settings for HandleEdge """Settings for HandleEdge
Values: Values:

View File

@ -1,44 +1,40 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"" # Copyright (C) 2007 Aaron Spike (aaron @ ekips.org)
# Copyright (C) 2007 Tavmjong Bah (tavmjong @ free.fr)
''' # Copyright (C) http://cnc-club.ru/forum/viewtopic.php?f=33&t=434&p=2594#p2500
Copyright (C) 2007 Aaron Spike (aaron @ ekips.org) # Copyright (C) 2014 Jürgen Weigert (juewei@fabmail.org)
Copyright (C) 2007 Tavmjong Bah (tavmjong @ free.fr) #
Copyright (C) http://cnc-club.ru/forum/viewtopic.php?f=33&t=434&p=2594#p2500 # This program is free software; you can redistribute it and/or modify
Copyright (C) 2014 Jürgen Weigert (juewei@fabmail.org) # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
This program is free software; you can redistribute it and/or modify # (at your option) any later version.
it under the terms of the GNU General Public License as published by #
the Free Software Foundation; either version 2 of the License, or # This program is distributed in the hope that it will be useful,
(at your option) any later version. # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
This program is distributed in the hope that it will be useful, # GNU General Public License for more details.
but WITHOUT ANY WARRANTY; without even the implied warranty of #
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # You should have received a copy of the GNU General Public License
GNU General Public License for more details. # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
You should have received a copy of the GNU General Public License #
along with this program; if not, write to the Free Software # 2014-03-20 jw@suse.de 0.2 Option --accuracy=0 for automatic added.
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # 2014-03-21 sent upstream: https://bugs.launchpad.net/inkscape/+bug/1295641
# 2014-03-21 jw@suse.de 0.3 Fixed center of rotation for gears with odd number of teeth.
2014-03-20 jw@suse.de 0.2 Option --accuracy=0 for automatic added. # 2014-04-04 juewei 0.7 Revamped calc_unit_factor().
2014-03-21 sent upstream: https://bugs.launchpad.net/inkscape/+bug/1295641 # 2014-04-05 juewei 0.7a Correctly positioned rack gear.
2014-03-21 jw@suse.de 0.3 Fixed center of rotation for gears with odd number of teeth. # The geometry above the meshing line is wrong.
2014-04-04 juewei 0.7 Revamped calc_unit_factor(). # 2014-04-06 juewei 0.7b Undercut detection added. Reference:
2014-04-05 juewei 0.7a Correctly positioned rack gear. # http://nptel.ac.in/courses/IIT-MADRAS/Machine_Design_II/pdf/2_2.pdf
The geometry above the meshing line is wrong. # Manually merged https://github.com/jnweiger/inkscape-gears-dev/pull/15
2014-04-06 juewei 0.7b Undercut detection added. Reference: # 2014-04-07 juewei 0.7c Manually merged https://github.com/jnweiger/inkscape-gears-dev/pull/17
http://nptel.ac.in/courses/IIT-MADRAS/Machine_Design_II/pdf/2_2.pdf # 2014-04-09 juewei 0.8 Fixed https://github.com/jnweiger/inkscape-gears-dev/issues/19
Manually merged https://github.com/jnweiger/inkscape-gears-dev/pull/15 # Ring gears are ready for production now. Thanks neon22 for driving this.
2014-04-07 juewei 0.7c Manually merged https://github.com/jnweiger/inkscape-gears-dev/pull/17 # Profile shift implemented (Advanced Tab), fixing
2014-04-09 juewei 0.8 Fixed https://github.com/jnweiger/inkscape-gears-dev/issues/19 # https://github.com/jnweiger/inkscape-gears-dev/issues/9
Ring gears are ready for production now. Thanks neon22 for driving this. # 2015-05-29 juewei 0.9 ported to inkscape 0.91
Profile shift implemented (Advanced Tab), fixing # AttributeError: 'module' object inkex has no attribute 'uutounit
https://github.com/jnweiger/inkscape-gears-dev/issues/9 # Fixed https://github.com/jnweiger/inkscape-gears-dev
2015-05-29 juewei 0.9 ported to inkscape 0.91
AttributeError: 'module' object inkex has no attribute 'uutounit
Fixed https://github.com/jnweiger/inkscape-gears-dev
'''
from math import pi, cos, sin, tan, radians, degrees, ceil, asin, acos, sqrt from math import pi, cos, sin, tan, radians, degrees, ceil, asin, acos, sqrt
from os import devnull # for debugging from os import devnull # for debugging
@ -57,12 +53,11 @@ def linspace(a,b,n):
return [a+x*(b-a)/(n-1) for x in range(0,n)] return [a+x*(b-a)/(n-1) for x in range(0,n)]
def involute_intersect_angle(Rb, R): def involute_intersect_angle(Rb, R):
" "
Rb, R = float(Rb), float(R) Rb, R = float(Rb), float(R)
return (sqrt(R**2 - Rb**2) / (Rb)) - (acos(Rb / R)) return (sqrt(R**2 - Rb**2) / (Rb)) - (acos(Rb / R))
def point_on_circle(radius, angle): def point_on_circle(radius, angle):
" return xy coord of the point at distance radius from origin at angle " """ return xy coord of the point at distance radius from origin at angle """
x = radius * cos(angle) x = radius * cos(angle)
y = radius * sin(angle) y = radius * sin(angle)
return (x, y) return (x, y)
@ -308,7 +303,7 @@ class Gears():
self.OptionParser.add_option("-A", "--accuracy", self.OptionParser.add_option("-A", "--accuracy",
action="store", type="int", action="store", type="int",
dest="accuracy", default=0, dest="accuracy", default=0,
help="Accuracy of involute: automatic: 5..20 (default), best: 20(default), medium 10, low: 5; good acuracy is important with a low tooth count") help="Accuracy of involute: automatic: 5..20 (default), best: 20(default), medium 10, low: 5; good accuracy is important with a low tooth count")
# Clearance: Radial distance between top of tooth on one gear to bottom of gap on another. # Clearance: Radial distance between top of tooth on one gear to bottom of gap on another.
self.OptionParser.add_option("", "--clearance", self.OptionParser.add_option("", "--clearance",
action="store", type="float", action="store", type="float",
@ -409,8 +404,7 @@ class Gears():
self.boxes.ctx.restore() self.boxes.ctx.restore()
def calc_circular_pitch(self): def calc_circular_pitch(self):
""" We use math based on circular pitch. """We use math based on circular pitch."""
"""
dimension = self.options.dimension dimension = self.options.dimension
if self.options.system == 'CP': # circular pitch if self.options.system == 'CP': # circular pitch
circular_pitch = dimension * 25.4 circular_pitch = dimension * 25.4

View File

@ -51,7 +51,7 @@ class BOX(Boxes): # Change class name!
space = 10, finger=10, space = 10, finger=10,
width=self.thickness) width=self.thickness)
p = edges.FingerJointEdge(self, s) p = edges.FingerJointEdge(self, s)
p.char = "a" # 'a', 'A', 'b' and 'B' is reserved for beeing used within generators p.char = "a" # 'a', 'A', 'b' and 'B' is reserved for being used within generators
self.addPart(p) self.addPart(p)
# render your parts here # render your parts here

View File

@ -654,7 +654,7 @@ protruding underneath.
def render_upper_token_trays(self, tray_inner_height, box_width): def render_upper_token_trays(self, tray_inner_height, box_width):
""" """
Upper level : multiple trays for each ressource Upper level : multiple trays for each resource
(beside horses which are on the lower level) (beside horses which are on the lower level)
""" """
tray_height = tray_inner_height + self.thickness tray_height = tray_inner_height + self.thickness

View File

@ -36,7 +36,7 @@ class BirdHouse(Boxes):
lengths = (x, h, t, roof, roof, t, h) lengths = (x, h, t, roof, roof, t, h)
edges = [self.edges.get(e, e) for e in edges] edges = [self.edges.get(e, e) for e in edges]
edges.append(edges[0]) # wrap arround edges.append(edges[0]) # wrap around
tw = x + edges[1].spacing() + edges[-2].spacing() tw = x + edges[1].spacing() + edges[-2].spacing()
th = h + x/2 + t + edges[0].spacing() + max(edges[3].spacing(), edges[4].spacing()) th = h + x/2 + t + edges[0].spacing() + max(edges[3].spacing(), edges[4].spacing())

View File

@ -19,7 +19,7 @@ from boxes import *
class BottleStack(Boxes): class BottleStack(Boxes):
"""Stack bottles in a fridge""" """Stack bottles in a fridge"""
description = """When rendered with the "double" option the parts with the double slots get connected the shorter beams in the asymetrical slots. description = """When rendered with the "double" option the parts with the double slots get connected the shorter beams in the asymmetrical slots.
Without the "double" option the stand is a bit more narrow. Without the "double" option the stand is a bit more narrow.
""" """

View File

@ -8,7 +8,7 @@
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERself.canHightANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
@ -83,7 +83,7 @@ for AA batteries:
![CanStorage for AA batteries](static/samples/CanStorageAA.jpg) ![CanStorage for AA batteries](static/samples/CanStorageAA.jpg)
for canned tomatos: for canned tomatoes:
""" """
@ -111,7 +111,7 @@ for canned tomatos:
help="outer diameter of the cans to be stored (in mm)") help="outer diameter of the cans to be stored (in mm)")
self.argparser.add_argument( self.argparser.add_argument(
"--canHight", action="store", type=float, default=110, "--canHight", action="store", type=float, default=110,
help="hight of the cans to be stored (in mm)") help="height of the cans to be stored (in mm)")
self.argparser.add_argument( self.argparser.add_argument(
"--canNum", action="store", type=int, default=12, "--canNum", action="store", type=int, default=12,
help="number of cans to be stored") help="number of cans to be stored")

View File

@ -18,7 +18,7 @@ from boxes import *
class Castle(Boxes): class Castle(Boxes):
"Castle tower with two walls" """Castle tower with two walls"""
description = """This was done as a table decoration. May be at some point in the future someone will create a proper castle description = """This was done as a table decoration. May be at some point in the future someone will create a proper castle
with towers and gates and walls that can be attached in multiple configurations.""" with towers and gates and walls that can be attached in multiple configurations."""

View File

@ -27,7 +27,7 @@ class CoffeeCapsuleHolder(Boxes):
ui_group = "Misc" ui_group = "Misc"
description = """ description = """
You can store your coffee capsule near your expresso machine with this. It works both vertically, or upside down under a shelf. You can store your coffee capsule near your espresso machine with this. It works both vertically, or upside down under a shelf.
""" """
def __init__(self): def __init__(self):

View File

@ -25,7 +25,7 @@ class Console2(Boxes):
This box is designed as a housing for electronic projects. It has hatches that can be re-opened with simple tools. It intentionally cannot be opened with bare hands - if build with thin enough material. This box is designed as a housing for electronic projects. It has hatches that can be re-opened with simple tools. It intentionally cannot be opened with bare hands - if build with thin enough material.
#### Caution #### Caution
There is a chance that the latches of the back wall or the back wall itself interfere with the front panel or it's mounting frame/lips. The generator does not check for this. So depending on the variant choosen you might need to make the box deeper (increase y parameter) or the panel angle steeper (increase angle parameter) until there is enough room. There is a chance that the latches of the back wall or the back wall itself interfere with the front panel or it's mounting frame/lips. The generator does not check for this. So depending on the variant chosen you might need to make the box deeper (increase y parameter) or the panel angle steeper (increase angle parameter) until there is enough room.
It's also possible that the frame of the panel interferes with the floor if the hi parameter is too small. It's also possible that the frame of the panel interferes with the floor if the hi parameter is too small.
@ -40,7 +40,7 @@ If the panel is removable you need to add the springs with the tabs to the side
![Back wall details](static/samples/Console2-panel-detail.jpg) ![Back wall details](static/samples/Console2-panel-detail.jpg)
If space is tight you may consider not glueing the cross pieces in place and remove them after the glue-up. This may prevent the latches of the back wall and the panel from interfereing with each other. If space is tight you may consider not gluing the cross pieces in place and remove them after the glue-up. This may prevent the latches of the back wall and the panel from interfering with each other.
The variant using finger joints only has the two side lips without the cross bars. The variant using finger joints only has the two side lips without the cross bars.

View File

@ -33,7 +33,7 @@ def offset_radius_in_square(squareside, angle, outset):
10.0 10.0
>>> offset_radius_in_square(20, 0, 5) >>> offset_radius_in_square(20, 0, 5)
10.0 10.0
>>> # Without offset, it's half squre length divided by cos(angle) -- at >>> # Without offset, it's half square length divided by cos(angle) -- at
>>> # least before it hits the next wall >>> # least before it hits the next wall
>>> offset_radius_in_square(20, 15, 0) # doctest:+ELLIPSIS >>> offset_radius_in_square(20, 15, 0) # doctest:+ELLIPSIS
10.35276... 10.35276...
@ -206,8 +206,8 @@ class DiscRack(Boxes):
# Can the discs be removed at all? # Can the discs be removed at all?
# Does not need explicit checking, for Thales' theorem tells us that at # Does not need explicit checking, for Thales' theorem tells us that at
# the point wher there is barely support in the corner, three contact # the point where there is barely support in the corner, three contact
# points on the circle form just a demicircle and the discs can be # points on the circle form just a semicircle and the discs can be
# inserted/removed. When we keep the other contact points and move the # inserted/removed. When we keep the other contact points and move the
# slits away from the corner, the disc gets smaller and thus will fit # slits away from the corner, the disc gets smaller and thus will fit
# through the opening that is as wide as the diameter of the largest # through the opening that is as wide as the diameter of the largest

View File

@ -18,7 +18,7 @@ from boxes import *
class Display(Boxes): class Display(Boxes):
"""Diplay for flyers or leaflets""" """Display for flyers or leaflets"""
ui_group = "Misc" ui_group = "Misc"

View File

@ -78,7 +78,7 @@ Adding '0:' at the start of the sy parameter adds a slot at the very back. Addin
There are 4 different sets of dividers rendered: There are 4 different sets of dividers rendered:
* With asymetric tabs so the tabs fit on top of each other * With asymmetric tabs so the tabs fit on top of each other
* With tabs of half wall thickness that can go side by side * With tabs of half wall thickness that can go side by side
* With tabs of a full wall thickness * With tabs of a full wall thickness
* One single divider spanning across all columns * One single divider spanning across all columns
@ -215,7 +215,7 @@ You will likely need to cut each of the dividers you want multiple times.
# Dividers # Dividers
divider_height = ( divider_height = (
# h, with angle adjustement # h, with angle adjustment
self.h / math.cos(math.radians(self.Slot_angle)) self.h / math.cos(math.radians(self.Slot_angle))
# removing what exceeds in the width of the divider # removing what exceeds in the width of the divider
- self.thickness * math.tan(math.radians(self.Slot_angle)) - self.thickness * math.tan(math.radians(self.Slot_angle))
@ -495,14 +495,14 @@ class SlotDescription:
def corrected_start_depth(self): def corrected_start_depth(self):
""" """
Returns the depth of the straigth part of the slot starting side Returns the depth of the straight part of the slot starting side
""" """
extra_depth = self._depth_angle_correction() extra_depth = self._depth_angle_correction()
return self.depth + max(0, extra_depth) - self.round_edge_start_correction() return self.depth + max(0, extra_depth) - self.round_edge_start_correction()
def corrected_end_depth(self): def corrected_end_depth(self):
""" """
Returns the depth of the straigth part of the slot ending side Returns the depth of the straight part of the slot ending side
""" """
extra_depth = self._depth_angle_correction() extra_depth = self._depth_angle_correction()
return self.depth + max(0, -extra_depth) - self.round_edge_end_correction() return self.depth + max(0, -extra_depth) - self.round_edge_end_correction()
@ -555,7 +555,7 @@ class SlotDescriptionsGenerator:
# Add this slot # Add this slot
descriptions.add(slot) descriptions.add(slot)
# Add the straigth edge after this slot # Add the straight edge after this slot
descriptions.add( descriptions.add(
StraightEdgeDescription(l, slot.round_edge_end_correction()) StraightEdgeDescription(l, slot.round_edge_end_correction())
) )
@ -634,7 +634,7 @@ class DividerSlotsEdge(edges.BaseEdge):
elif isinstance(description, StraightEdgeDescription): elif isinstance(description, StraightEdgeDescription):
self.do_straight_edge(description) self.do_straight_edge(description)
# rounding errors might accumulates : # rounding errors might accumulate :
# restore context and redo the move straight # restore context and redo the move straight
self.ctx.restore() self.ctx.restore()
self.moveTo(length) self.moveTo(length)
@ -656,7 +656,7 @@ class DividerSlotsEdge(edges.BaseEdge):
(90 + slot.angle, slot.end_radius), (90 + slot.angle, slot.end_radius),
) )
# rounding errors might accumulates : # rounding errors might accumulate :
# restore context and redo the move straight # restore context and redo the move straight
self.ctx.restore() self.ctx.restore()
self.moveTo(slot.tracing_length()) self.moveTo(slot.tracing_length())

View File

@ -21,13 +21,13 @@ from boxes import *
class DrillStand(Boxes): class DrillStand(Boxes):
"""Box for drills with each compartment of a different height""" """Box for drills with each compartment of a different height"""
description = """Note: `sh` gives the hight of the rows front to back. It though should have the same number of entries as `sy`. These heights are the one on the left side and increase throughout the row. To have each compartement a bit higher than the previous one the steps in `sh` should be a bit bigger than `extra_height`. description = """Note: `sh` gives the hight of the rows front to back. It though should have the same number of entries as `sy`. These heights are the one on the left side and increase throughout the row. To have each compartment a bit higher than the previous one the steps in `sh` should be a bit bigger than `extra_height`.
Assembly: Assembly:
![Parts](static/samples/DrillStand-drawing.png) ![Parts](static/samples/DrillStand-drawing.png)
Start with putting the slots of the inner walls together. Be especially careful with adding the bottom. It is always assymetrical and flush with the right/lower side while being a little short on the left/higher side to not protrude into the side wall. Start with putting the slots of the inner walls together. Be especially careful with adding the bottom. It is always asymmetrical and flush with the right/lower side while being a little short on the left/higher side to not protrude into the side wall.
| | | | | |
| ---- | ---- | | ---- | ---- |

View File

@ -17,7 +17,7 @@
from boxes import * from boxes import *
class Edges(Boxes): class Edges(Boxes):
"""Print all registerd Edge types""" """Print all registered Edge types"""
webinterface = False webinterface = False

View File

@ -18,7 +18,7 @@ from boxes import *
class FlexTest(Boxes): class FlexTest(Boxes):
"Piece for testing different flex settings" """Piece for testing different flex settings"""
ui_group = "Part" ui_group = "Part"

View File

@ -18,7 +18,7 @@ from boxes import *
class FlexTest2(Boxes): class FlexTest2(Boxes):
"Piece for testing 2D flex settings" """Piece for testing 2D flex settings"""
ui_group = "Part" ui_group = "Part"

View File

@ -33,7 +33,7 @@ class GearBox(Boxes):
help="number of teeth on outgoing shaft") help="number of teeth on outgoing shaft")
self.argparser.add_argument( self.argparser.add_argument(
"--modulus", action="store", type=float, default=3, "--modulus", action="store", type=float, default=3,
help="modulus of the theeth in mm") help="modulus of the teeth in mm")
self.argparser.add_argument( self.argparser.add_argument(
"--shaft", action="store", type=float, default=6., "--shaft", action="store", type=float, default=6.,
help="diameter of the shaft") help="diameter of the shaft")

View File

@ -17,7 +17,7 @@
from boxes import * from boxes import *
class HeartBox(Boxes): class HeartBox(Boxes):
"""Box in the form of an heart""" """Box in the form of a heart"""
ui_group = "FlexBox" ui_group = "FlexBox"

View File

@ -20,7 +20,7 @@ class HingeBox(Boxes):
"""Box with lid attached by cabinet hinges""" """Box with lid attached by cabinet hinges"""
description = """Needs (metal) pins as hinge axles. Pieces of nails will description = """Needs (metal) pins as hinge axles. Pieces of nails will
do fine. They need to be cut to length as they are caputured as soon as the do fine. They need to be cut to length as they are captured as soon as the
hinges are assembled. hinges are assembled.
Assemble the box and the lid separately. Then insert the axle into the hinges. Assemble the box and the lid separately. Then insert the axle into the hinges.

View File

@ -18,7 +18,7 @@ from boxes import *
class Hook(Boxes): class Hook(Boxes):
"""A hook wit a rectangular mouth to mount at the wall""" """A hook with a rectangular mouth to mount at the wall"""
ui_group = "Misc" # see ./__init__.py for names ui_group = "Misc" # see ./__init__.py for names
@ -40,7 +40,7 @@ class Hook(Boxes):
help="width of the hook from the side") help="width of the hook from the side")
self.argparser.add_argument("--angle", action="store", self.argparser.add_argument("--angle", action="store",
type=float, default=45., type=float, default=45.,
help="angle of the support underneeth") help="angle of the support underneath")
def render(self): def render(self):

View File

@ -18,7 +18,7 @@ from boxes import *
class JigsawPuzzle(Boxes): # change class name here and below class JigsawPuzzle(Boxes): # change class name here and below
"""Fractal jigsaw puzzle. Still aplha""" """Fractal jigsaw puzzle. Still alpha."""
webinterface = False # Change to make visible in web interface webinterface = False # Change to make visible in web interface

View File

@ -117,7 +117,6 @@ class Keyboard:
Spaces are not important. Spaces are not important.
For example '3x2 / 4@11' means we want 3 columns, the two first with For example '3x2 / 4@11' means we want 3 columns, the two first with
3 rows without offset, and the last with 4 rows starting at 11mm high 3 rows without offset, and the last with 4 rows starting at 11mm high
""" """
result = [] result = []
try: try:
@ -245,7 +244,7 @@ class Keyboard:
A simple plate cutout, a 14mm rectangle, as specified in this reference sheet A simple plate cutout, a 14mm rectangle, as specified in this reference sheet
https://cdn.sparkfun.com/datasheets/Components/Switches/MX%20Series.pdf https://cdn.sparkfun.com/datasheets/Components/Switches/MX%20Series.pdf
With_notch shoul be used for a secondary lower plate, strengthening the first one. With_notch should be used for a secondary lower plate, strengthening the first one.
A notch is added to let the hooks grasp the main upper plate. A notch is added to let the hooks grasp the main upper plate.
Current position should be switch center. Current position should be switch center.

View File

@ -109,7 +109,7 @@ class Keypad(Boxes, Keyboard):
return [callback] return [callback]
def hotplug(self): def hotplug(self):
"""Callback for the key stabelizers.""" """Callback for the key stabilizers."""
self.pcb_holes( self.pcb_holes(
with_pcb_mount=self.pcb_mount_enable, with_pcb_mount=self.pcb_mount_enable,
with_diode=self.diode_enable, with_diode=self.diode_enable,

View File

@ -20,7 +20,7 @@ class LaserClamp(Boxes):
"""A clamp to hold down material to a knife table""" """A clamp to hold down material to a knife table"""
description = """You need a tension spring of the proper length to make the clamp work. description = """You need a tension spring of the proper length to make the clamp work.
Increace extraheight to get more space for the spring and to make the Increase extraheight to get more space for the spring and to make the
sliding mechanism less likely to bind. You may need to add some wax on the sliding mechanism less likely to bind. You may need to add some wax on the
parts sliding on each other to reduce friction. parts sliding on each other to reduce friction.
""" """

View File

@ -17,7 +17,7 @@
from boxes import * from boxes import *
class NemaMount(Boxes): class NemaMount(Boxes):
"""Mounting braket for a Nema motor""" """Mounting bracket for a Nema motor"""
ui_group = "Part" ui_group = "Part"

View File

@ -48,7 +48,7 @@ class PaintStorage(Boxes):
help="Create a stackable drawer instead") help="Create a stackable drawer instead")
def paintholes(self): def paintholes(self):
"Place holes for the paintcans evenly" """Place holes for the paintcans evenly"""
if self.hexpattern: if self.hexpattern:
self.moveTo(self.minspace/2, self.minspace/2) self.moveTo(self.minspace/2, self.minspace/2)

View File

@ -30,7 +30,7 @@ class PaperBox(Boxes):
This box is made of paper. This box is made of paper.
There is marks in the "outside leftover paper" to help see where to fold There is marks in the "outside leftover paper" to help see where to fold
(cutting with tabs helps use them). The cut is very precise, and could be too tight if misaligned when glued. A plywood box (such as a simple TypeTray) of the same size is a great guide during folding and glueing. Just fold the box against it. Accurate quick and easy. (cutting with tabs helps use them). The cut is very precise, and could be too tight if misaligned when glued. A plywood box (such as a simple TypeTray) of the same size is a great guide during folding and gluing. Just fold the box against it. Accurate quick and easy.
A paper creaser (or bone folder) is also useful. A paper creaser (or bone folder) is also useful.
""" """

View File

@ -18,7 +18,6 @@ from boxes import *
class Planetary(Boxes): class Planetary(Boxes):
"""Planetary Gear with possibly multiple identical stages""" """Planetary Gear with possibly multiple identical stages"""
ui_group = "Part" ui_group = "Part"

View File

@ -18,7 +18,6 @@ from boxes import *
class Planetary2(Boxes): class Planetary2(Boxes):
"""Balanced force Difference Planetary Gear (not yet working properly)""" """Balanced force Difference Planetary Gear (not yet working properly)"""
ui_group = "Unstable" ui_group = "Unstable"
@ -46,7 +45,7 @@ class Planetary2(Boxes):
help="enable secondary ring with given delta to the ring gear") help="enable secondary ring with given delta to the ring gear")
self.argparser.add_argument( self.argparser.add_argument(
"--modulus", action="store", type=float, default=1.0, "--modulus", action="store", type=float, default=1.0,
help="modulus of the theeth in mm") help="modulus of the teeth in mm")
self.argparser.add_argument( self.argparser.add_argument(
"--shaft", action="store", type=float, default=6., "--shaft", action="store", type=float, default=6.,
help="diameter of the shaft") help="diameter of the shaft")
@ -132,7 +131,7 @@ class Planetary2(Boxes):
def planets(): def planets():
self.moveTo(size3/2, size3/2) self.moveTo(size3/2, size3/2)
for angle in planetpositions: for angle in planetpositions:
angle += 180 # compensate for 3 postion in callback angle += 180 # compensate for 3 position in callback
self.moveTo(0, 0, angle) self.moveTo(0, 0, angle)
self.hole((pitch1+pitch2), 0, size2/2) self.hole((pitch1+pitch2), 0, size2/2)
self.moveTo(0, 0, -angle) self.moveTo(0, 0, -angle)

View File

@ -24,7 +24,7 @@ class SlotEdge(edges.Edge):
r, h = self.settings.radius, self.settings.h r, h = self.settings.radius, self.settings.h
sh = self.settings.sh # distance side to center sh = self.settings.sh # distance side to center
li = 2 * sh * math.tan(math.radians(90/n)) # side inner 2x polygone li = 2 * sh * math.tan(math.radians(90/n)) # side inner 2x polygon
ls2 = t / math.tan(math.radians(180/n)) ls2 = t / math.tan(math.radians(180/n))
ls1 = t / math.cos(math.radians(90-(180/n))) ls1 = t / math.cos(math.radians(90-(180/n)))

View File

@ -80,7 +80,6 @@ class RollerEdge2(edges.BaseEdge):
class Rotary(Boxes): class Rotary(Boxes):
"""Rotary Attachment for engraving cylindrical objects in a laser cutter""" """Rotary Attachment for engraving cylindrical objects in a laser cutter"""
ui_group = "Unstable" ui_group = "Unstable"
@ -101,7 +100,7 @@ class Rotary(Boxes):
help="diameter of the axles") help="diameter of the axles")
self.argparser.add_argument( self.argparser.add_argument(
"--knifethickness", action="store", type=float, default=8., "--knifethickness", action="store", type=float, default=8.,
help="thickness of the knifes in mm. Use 0 for use with honey comb table.") help="thickness of the knives in mm. Use 0 for use with honey comb table.")
self.argparser.add_argument( self.argparser.add_argument(
"--beamwidth", action="store", type=float, default=32., "--beamwidth", action="store", type=float, default=32.,
help="width of the (aluminium) profile connecting the parts") help="width of the (aluminium) profile connecting the parts")
@ -252,7 +251,7 @@ class Rotary(Boxes):
with self.saved_context(): with self.saved_context():
self.rectangularWall(hw - 2 * t - 2, 60, edges="efef", move="right") self.rectangularWall(hw - 2 * t - 2, 60, edges="efef", move="right")
self.rectangularWall(hw - 4 * t - 4, 60, edges="efef", move="right") self.rectangularWall(hw - 4 * t - 4, 60, edges="efef", move="right")
# Spindel auxiliaries # Spindle auxiliaries
self.parts.waivyKnob(50, callback=lambda: self.nutHole("M8"), move="right") self.parts.waivyKnob(50, callback=lambda: self.nutHole("M8"), move="right")
self.parts.waivyKnob(50, callback=lambda: self.nutHole("M8"), move="right") self.parts.waivyKnob(50, callback=lambda: self.nutHole("M8"), move="right")

View File

@ -13,7 +13,7 @@ class SlidingDrawer(Boxes):
self.argparser.add_argument( self.argparser.add_argument(
"--play", action="store", type=float, default=0.15, "--play", action="store", type=float, default=0.15,
help="play between the two parts as multipleof the wall thickness") help="play between the two parts as multiple of the wall thickness")
def render(self): def render(self):

View File

@ -89,7 +89,7 @@ class TrayLayout2(TrayLayout):
description = """Edit the layout text graphics to adjust your tray. description = """Edit the layout text graphics to adjust your tray.
Put in the sizes for each column and row. You can replace the hyphens and Put in the sizes for each column and row. You can replace the hyphens and
vertial bars representing the walls with a space character to remove the walls. vertical bars representing the walls with a space character to remove the walls.
You can replace the space characters representing the floor by a "X" to remove the floor for this compartment. You can replace the space characters representing the floor by a "X" to remove the floor for this compartment.
""" """
@ -112,7 +112,7 @@ You can replace the space characters representing the floor by a "X" to remove t
close = Boxes.close close = Boxes.close
def vWalls(self, x, y): def vWalls(self, x, y):
"Number of vertical walls at a crossing" """Number of vertical walls at a crossing"""
result = 0 result = 0
if y > 0 and self.vwalls[y - 1][x]: if y > 0 and self.vwalls[y - 1][x]:
result += 1 result += 1
@ -123,7 +123,7 @@ You can replace the space characters representing the floor by a "X" to remove t
return result return result
def hWalls(self, x, y): def hWalls(self, x, y):
"Number of horizontal walls at a crossing" """Number of horizontal walls at a crossing"""
result = 0 result = 0
if x > 0 and self.hwalls[y][x - 1]: if x > 0 and self.hwalls[y][x - 1]:
result += 1 result += 1
@ -132,12 +132,12 @@ You can replace the space characters representing the floor by a "X" to remove t
return result return result
def vFloor(self, x, y): def vFloor(self, x, y):
"Is there floor under vertical wall" """Is there floor under vertical wall"""
return ((x > 0 and self.floors[y][x - 1]) or return ((x > 0 and self.floors[y][x - 1]) or
(x < len(self.x) and self.floors[y][x])) (x < len(self.x) and self.floors[y][x]))
def hFloor(self, x, y): def hFloor(self, x, y):
"Is there foor under horizontal wall" """Is there foor under horizontal wall"""
return ((y > 0 and self.floors[y - 1][x]) or return ((y > 0 and self.floors[y - 1][x]) or
(y < len(self.y) and self.floors[y][x])) (y < len(self.y) and self.floors[y][x]))

View File

@ -23,7 +23,7 @@ class TwoPiece(Boxes):
""" """
description = """ description = """
Set *hi* larger than *h* to leave gap between the inner and outer shell. This can be used to make opening the box easier. Set *hi* smaller to only have a small inner ridge that will allow the content to be momre visible after opening. Set *hi* larger than *h* to leave gap between the inner and outer shell. This can be used to make opening the box easier. Set *hi* smaller to only have a small inner ridge that will allow the content to be more visible after opening.
![Bottom view](static/samples/TwoPiece2.jpg) ![Bottom view](static/samples/TwoPiece2.jpg)
""" """
@ -37,7 +37,7 @@ Set *hi* larger than *h* to leave gap between the inner and outer shell. This ca
self.argparser.add_argument( self.argparser.add_argument(
"--play", action="store", type=float, default=0.15, "--play", action="store", type=float, default=0.15,
help="play between the two parts as multipleof the wall thickness") help="play between the two parts as multiple of the wall thickness")
def render(self): def render(self):
# adjust to the variables you want in the local scope # adjust to the variables you want in the local scope

View File

@ -30,7 +30,7 @@ class TypeTray(_TopEdge):
"top_edge") "top_edge")
self.argparser.add_argument( self.argparser.add_argument(
"--back_height", action="store", type=float, default=0.0, "--back_height", action="store", type=float, default=0.0,
help="additional height of the back wall - e top egde only") help="additional height of the back wall - e top edge only")
self.argparser.add_argument( self.argparser.add_argument(
"--radius", action="store", type=float, default=0.0, "--radius", action="store", type=float, default=0.0,
help="radius for strengthening side walls with back_height") help="radius for strengthening side walls with back_height")

View File

@ -30,7 +30,7 @@ class WallCaliper(_WallMountedBox):
help="width of the long end") help="width of the long end")
self.argparser.add_argument( self.argparser.add_argument(
"--heigth", action="store", type=float, default=6.0, "--heigth", action="store", type=float, default=6.0,
help="heigth of the body") help="height of the body")
def side(self, move=None): def side(self, move=None):
t = self.thickness t = self.thickness

View File

@ -27,10 +27,10 @@ class WallPlaneHolder(_WallMountedBox):
help="width of the plane") help="width of the plane")
self.argparser.add_argument( self.argparser.add_argument(
"--length", action="store", type=float, default=250, "--length", action="store", type=float, default=250,
help="legth of the plane") help="length of the plane")
self.argparser.add_argument( self.argparser.add_argument(
"--hold_length", action="store", type=float, default=30, "--hold_length", action="store", type=float, default=30,
help="legth of the part hiolding the plane over the front") help="length of the part holding the plane over the front")
self.argparser.add_argument( self.argparser.add_argument(
"--height", action="store", type=float, default=80, "--height", action="store", type=float, default=80,
help="height of the front of plane") help="height of the front of plane")

View File

@ -33,7 +33,8 @@ class Parts:
:param diameter: diameter of the disc :param diameter: diameter of the disc
:param hole: (Default value = 0) :param hole: (Default value = 0)
:param callback: (Default value = None) called in the center :param callback: (Default value = None) called in the center
:param move: (Defaultvalue = None) :param move: (Default value = "")
:param label: (Default value = "")
""" """
size = diameter size = diameter
r = diameter / 2.0 r = diameter / 2.0
@ -59,7 +60,7 @@ class Parts:
:param angle: (Default value = 45) maximum angle of the wave :param angle: (Default value = 45) maximum angle of the wave
:param hole: (Default value = 0) :param hole: (Default value = 0)
:param callback: (Default value = None) called in the center :param callback: (Default value = None) called in the center
:param move: (Defaultvalue = None) :param move: (Default value = "")
""" """
if n < 2: if n < 2:
@ -92,11 +93,11 @@ class Parts:
:param diameter: diameter of the knob :param diameter: diameter of the knob
:param n: (Default value = 3) number of dents :param n: (Default value = 3) number of dents
:param rounded: (Default value = 0.2) proportion of circumferen remaining :param rounded: (Default value = 0.2) proportion of circumference remaining
:param angle: (Default value = 70) angle the dents meet the circumference :param angle: (Default value = 70) angle the dents meet the circumference
:param hole: (Default value = 0) :param hole: (Default value = 0)
:param callback: (Default value = None) called in the center :param callback: (Default value = None) called in the center
:param move: (Defaultvalue = None) :param move: (Default value = "")
""" """
size = diameter size = diameter
@ -132,9 +133,9 @@ class Parts:
:param r_outside: outer radius :param r_outside: outer radius
:param r_inside: inner radius :param r_inside: inner radius
:param angle: anlge the segment is spanning :param angle: angle the segment is spanning
:param n: (Default value = 1) number of segments :param n: (Default value = 1) number of segments
:param move: (Defaultvalue = None) :param move: (Default value = "")
""" """
space = 360 * r_inside / self.spacing space = 360 * r_inside / self.spacing
n = min(n, 360 / (angle+space)) n = min(n, 360 / (angle+space))

View File

@ -16,7 +16,7 @@ import math
def normalize(v): def normalize(v):
"set lenght of vector to one" """set length of vector to one"""
l = (v[0] ** 2 + v[1] ** 2) ** 0.5 l = (v[0] ** 2 + v[1] ** 2) ** 0.5
if l == 0.0: if l == 0.0:
return (0.0, 0.0) return (0.0, 0.0)
@ -35,35 +35,34 @@ def vclip(v, length):
def vdiff(p1, p2): def vdiff(p1, p2):
"vector from point1 to point2" """vector from point1 to point2"""
return (p2[0] - p1[0], p2[1] - p1[1]) return (p2[0] - p1[0], p2[1] - p1[1])
def vadd(v1, v2): def vadd(v1, v2):
"Sum of two vectors" """Sum of two vectors"""
return (v1[0] + v2[0], v1[1] + v2[1]) return (v1[0] + v2[0], v1[1] + v2[1])
def vorthogonal(v): def vorthogonal(v):
"orthogonal vector" """Orthogonal vector"""
"Orthogonal vector"
return (-v[1], v[0]) return (-v[1], v[0])
def vscalmul(v, a): def vscalmul(v, a):
"scale vector by a" """scale vector by a"""
return (a * v[0], a * v[1]) return (a * v[0], a * v[1])
def dotproduct(v1, v2): def dotproduct(v1, v2):
"Dot product" """Dot product"""
return v1[0] * v2[0] + v1[1] * v2[1] return v1[0] * v2[0] + v1[1] * v2[1]
def circlepoint(r, a): def circlepoint(r, a):
return (r * math.cos(a), r * math.sin(a)) return (r * math.cos(a), r * math.sin(a))
def tangent(x, y, r): def tangent(x, y, r):
"angle and length of a tangent to a circle at x,y with raduis r" """angle and length of a tangent to a circle at x,y with radius r"""
l1 = vlength((x, y)) l1 = vlength((x, y))
a1 = math.atan2(y, x) a1 = math.atan2(y, x)
a2 = math.asin(r / l1) a2 = math.asin(r / l1)
@ -72,7 +71,7 @@ def tangent(x, y, r):
return (a1+a2, l2) return (a1+a2, l2)
def rotm(angle): def rotm(angle):
"Rotation matrix" """Rotation matrix"""
return [[math.cos(angle), -math.sin(angle), 0], return [[math.cos(angle), -math.sin(angle), 0],
[math.sin(angle), math.cos(angle), 0]] [math.sin(angle), math.cos(angle), 0]]

View File

@ -159,7 +159,6 @@ class WallHoleEdge(WallHoles):
return 0.0 return 0.0
class WallSettings(Settings): class WallSettings(Settings):
"""Settings for plain WallEdges """Settings for plain WallEdges
Values: Values:
@ -262,7 +261,6 @@ class SlatWallEdge(WallEdge):
return self.settings.hook_depth + self.settings.hook_distance return self.settings.hook_depth + self.settings.hook_distance
class SlatWallSettings(WallSettings): class SlatWallSettings(WallSettings):
"""Settings for SlatWallEdges """Settings for SlatWallEdges
Values: Values:
@ -338,7 +336,6 @@ class DinRailEdge(WallEdge):
return self.settings.depth return self.settings.depth
class DinRailSettings(WallSettings): class DinRailSettings(WallSettings):
"""Settings for DinRailEdges """Settings for DinRailEdges
Values: Values:
@ -416,7 +413,6 @@ class FrenchCleatEdge(WallEdge):
return self.settings.depth return self.settings.depth
class FrenchCleatSettings(WallSettings): class FrenchCleatSettings(WallSettings):
"""Settings for FrenchCleatEdges """Settings for FrenchCleatEdges
Values: Values:

View File

@ -19,8 +19,8 @@ form. The user interfaces are located in `scripts/`. Currently there is
Generators Generators
.......... ..........
A (box) generator is an sub class of boxes.Boxes. It generates one A (box) generator is an subclass of boxes.Boxes. It generates one
drawing. The sub classes over load .__init__() to set their parameters drawing. The subclasses over load .__init__() to set their parameters
and implement .render() that does the actual drawing. and implement .render() that does the actual drawing.
Generators are found in ``boxes/generators/``. They are included into Generators are found in ``boxes/generators/``. They are included into

View File

@ -54,7 +54,7 @@ A similar approach is necessary when moving to a feature drawn inside
the part without the use of callbacks. Here you typically have to the part without the use of callbacks. Here you typically have to
correct for the out-set at the outside of the part and again for in-set correct for the out-set at the outside of the part and again for in-set
of the hole one is about to cut. This can be done in **x** or **y** of the hole one is about to cut. This can be done in **x** or **y**
direction depending on whether the cut ist started vertical or direction depending on whether the cut is started vertical or
horizontally. horizontally.
Replacing the inverted arcs Replacing the inverted arcs

View File

@ -44,7 +44,7 @@ Draw Commands
------------- -------------
These commands do not change the coordinate system but get the These commands do not change the coordinate system but get the
coordinates passed as parameters. All of them are either som sort of coordinates passed as parameters. All of them are either some sort of
hole or text. These artifacts are placed somewhere independently of hole or text. These artifacts are placed somewhere independently of
some continuous outline of the part their on. some continuous outline of the part their on.

View File

@ -2,11 +2,11 @@
Generators Generators
========== ==========
Generators are sub classes of Generators are subclasses of
.. autoclass:: boxes.Boxes .. autoclass:: boxes.Boxes
Most code is directly in this class. Sub class are supposed to over Most code is directly in this class. Subclass are supposed to over
write the ``.__init__()`` and ``.render()`` method. write the ``.__init__()`` and ``.render()`` method.
The Boxes class keeps a canvas object (self.ctx) that all The Boxes class keeps a canvas object (self.ctx) that all
@ -18,7 +18,7 @@ For implementing a new generator forking an existing one or using the
``boxes/generators/_template.py`` is probably easier than starting ``boxes/generators/_template.py`` is probably easier than starting
from scratch. from scratch.
Many methods and attributes are for use of the sub classes. These Many methods and attributes are for use of the subclasses. These
methods are the interface for the user interfaces to interact with the methods are the interface for the user interfaces to interact with the
generators: generators:

View File

@ -34,7 +34,7 @@ Setup.py uses the :code:`setuptools` library (package name may be
package. package.
pstoedit pstoedit
....... ........
While not a hard requirement Boxes.py uses :code:`pstoedit` (sometimes :code:`ps2edit`) to offer formats While not a hard requirement Boxes.py uses :code:`pstoedit` (sometimes :code:`ps2edit`) to offer formats
that are not supported by Cairo: DXF, gcode, PLT. Currently the location that are not supported by Cairo: DXF, gcode, PLT. Currently the location