There are a few parameter shared by many of those parts:
The callback parameter¶
The callback parameter can take on of the following forms:
A function (or bound method) that expects one parameter: the number of the side the callback is currently called for.
A dict with some of the numbers of the sides as keys and functions without parameters as values.
A list of functions without parameters. The list may contain None as place holder and be shorter than the number of sides.
The callback functions are called with the side of the part at the positive x and y axis. If the edge uses up space this space is below the x axis. You do not have to restore the coordinate settings in the callback.
Instead of functions it can be handy to use a lambda expression calling the one building block function you need (e.g. fingerHolesAt).
For your own parts you can use this helper function:
- Boxes.cc(callback, number, x=0.0, y=None)¶
Call callback from edge of a part
callback – callback (callable or list of callables)
number – number of the callback
x – (Default value = 0.0) x position to be call on
y – (Default value = None) y position to be called on (default does burn correction)
For finding the right piece to the callback parameter this function is used:
- Boxes.getEntry(param, idx)¶
Get entry from list or items itself
param – list or item
idx – index in list
The move parameter¶
For placing the parts the
move parameter can be used. It is string
with space separated words - at most one of each of those options:
left / right
up / down
If “only” is given the part is not drawn but only the move is
done. This can be useful to go in one direction after having placed
multiple parts in the other and have returned with
For implementing parts the following helper function can be used to
- Boxes.move(x, y, where, before=False, label='')¶
Intended to be used by parts where can be combinations of “up” or “down”, “left” or “right”, “only”, “mirror” and “rotated” when “only” is included the move is only done when before is True “mirror” will flip the part along the y axis “rotated” draws the parts rotated 90 counter clockwise The function returns whether actual drawing of the part should be ommited.
x – width of part
y – height of part
where – which direction to move
before – (Default value = False) called before or after part being drawn
It needs to be called before and after drawing the actual part with
before parameter set.
The edges parameter¶
edges parameter needs to be an iterable of Edge instances to be
used as edges of the part. Instead of instances it is possible to pass
a single character that is looked up in the
.edges dict. This
allows to pass a string with the desired characters per edge. By
default the following character are supported:
e : straight edge
E : as above but extended outside by one thickness
f, F : finger joints
h : edge with holes for finger joints
d, D : dove tail joints
Generators can register their own Edges by putting them into the
Same applies to the parameters of
.surroundingWall although they
denominate single edge (types) only.
To place many of the same part partMatrix can used:
- Boxes.partsMatrix(n, width, move, part, *l, **kw)¶
place many of the same part
n – number of parts
width – number of parts in a row (0 for same as n)
move – (Default value = None)
part – callable that draws a part and knows move param
*l – params for part
**kw – keyword params for part
It creates one big block of parts. The move param treat this block like on big part.