boxes package

Subpackage boxes.generators

class boxes.generators.UIGroup(name, title=None, description='')[source]

Bases: object

add(box)[source]
boxes.generators.getAllBoxGenerators()[source]
boxes.generators.getAllGeneratorModules()[source]

All Box Generators

Submodules

boxes.Color module

class boxes.Color.Color[source]

Bases: object

BLACK = [0.0, 0.0, 0.0]
BLUE = [0.0, 0.0, 1.0]
GREEN = [0.0, 1.0, 0.0]
RED = [1.0, 0.0, 0.0]
WHITE = [1.0, 1.0, 1.0]

boxes.edges module

class boxes.edges.BaseEdge(boxes, settings)[source]

Bases: object

Abstract base class for all Edges

char = None
description = 'Abstract Edge Class'
endAngle()[source]

Not yet supported

endwidth()[source]
margin()[source]

Space needed right of the starting point

spacing()[source]

Space the edge needs outside of the inner space of the part

startAngle()[source]

Not yet supported

startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.BoltPolicy[source]

Bases: object

Abstract class

Distributes (bed) bolts on a number of segments (fingers of a finger joint)

drawbolt(pos)[source]

Add a bolt to this segment?

Parameters

pos – number of the finger

numFingers(numfingers)[source]

Return next smaller, possible number of fingers

Parameters

numfingers – number of fingers to aim for

class boxes.edges.Bolts(bolts=1)[source]

Bases: boxes.edges.BoltPolicy

Distribute a fixed number of bolts evenly

drawBolt(pos)[source]

Return if this finger needs a bolt

Parameters

pos – number of this finger

numFingers(numFingers)[source]

Return next smaller, possible number of fingers

Parameters

numfingers – number of fingers to aim for

class boxes.edges.CabinetHingeEdge(boxes, settings=None, top=False, angled=False)[source]

Bases: boxes.edges.BaseEdge

Edge with cabinet hinges

char = 'u'
description = 'Edge with cabinet hinges'
parts(move=None)[source]
startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.CabinetHingeSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for Cabinet Hinges Values:

  • absolute_params

  • bore : 3.2 : diameter of the pin hole in mm

  • eyes_per_hinge : 5 : pieces per hinge

  • hinges : 2 : number of hinges per edge

  • style : inside : style of hinge used

  • relative (in multiples of thickness)

  • eye : 1.5 : radius of the eye (in multiples of thickness)

  • play : 0.05 : space between eyes (in multiples of thickness)

  • spacing : 2.0 : minimum space around the hinge

absolute_params = {'bore': 3.2, 'eyes_per_hinge': 5, 'hinges': 2, 'style': ('inside', 'outside')}
edgeObjects(boxes, chars='uUvV', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'eye': 1.5, 'play': 0.05, 'spacing': 2.0}
class boxes.edges.ChestHinge(boxes, settings=None, reversed=False)[source]

Bases: boxes.edges.BaseEdge

char = 'o'
description = 'Edge with chest hinge'
endwidth()[source]
margin()[source]

Space needed right of the starting point

startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.ChestHingeFront(boxes, settings)[source]

Bases: boxes.edges.Edge

char = 'Q'
description = 'Edge opposing a chest hinge'
startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.ChestHingePin(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

char = 'q'
description = 'Edge with pins for an chest hinge'
margin()[source]

Space needed right of the starting point

class boxes.edges.ChestHingeSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for Chest Hinges Values:

  • relative (in multiples of thickness)

  • pin_height : 2.0 : radius of the disc rotating in the hinge

  • hinge_strength : 1.0 : thickness of the arc holding the pin in place

checkValues()[source]

Check if all values are in the right range. Raise ValueError if needed

edgeObjects(boxes, chars='oOpPqQ', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

pinheight()[source]
relative_params = {'hinge_strength': 1.0, 'pin_height': 2.0, 'play': 0.1}
class boxes.edges.ChestHingeTop(boxes, settings=None, reversed=False)[source]

Bases: boxes.edges.ChestHinge

Edge above a chest hinge

char = 'p'
endwidth()[source]
margin()[source]

Space needed right of the starting point

startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.ClickConnector(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

char = 'c'
description = 'Click on (bottom side)'
finger(length)[source]
hook(reverse=False)[source]
hookOffset()[source]
hookWidth()[source]
margin()[source]

Space needed right of the starting point

class boxes.edges.ClickEdge(boxes, settings)[source]

Bases: boxes.edges.ClickConnector

char = 'C'
description = 'Click on (top)'
margin()[source]

Space needed right of the starting point

startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.ClickSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for Click-on Lids

absolute_params = {'angle': 5}
edgeObjects(boxes, chars='cC', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'bottom_radius': 0.1, 'depth': 3.0}
class boxes.edges.CompoundEdge(boxes, types, lengths)[source]

Bases: boxes.edges.BaseEdge

Edge composed of multiple different Edges

description = 'Compound Edge'
endwidth()[source]
margin()[source]

Space needed right of the starting point

startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.CrossingFingerHoleEdge(boxes, height, fingerHoles=None, **kw)[source]

Bases: boxes.edges.Edge

Edge with holes for finger joints 90° above

char = '|'
description = 'Edge (orthogonal Finger Joint Holes)'
class boxes.edges.DoveTailJoint(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

Edge with dove tail joints

char = 'd'
description = 'Dove Tail Joint'
margin()[source]
positive = True
class boxes.edges.DoveTailJointCounterPart(boxes, settings)[source]

Bases: boxes.edges.DoveTailJoint

Edge for other side of dove joints

char = 'D'
description = 'Dove Tail Joint (opposing side)'
margin()[source]
positive = False
class boxes.edges.DoveTailSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for Dove Tail Joints

Values:

  • absolute

    • angle : 50 : how much should fingers widen (-80 to 80)

  • relative (in multiples of thickness)

    • size : 3 : from one middle of a dove tail to another

    • depth : 1.5 : how far the dove tails stick out of/into the edge

    • radius : 0.2 : radius used on all four corners

absolute_params = {'angle': 50}
edgeObjects(boxes, chars='dD', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'depth': 1.5, 'radius': 0.2, 'size': 3}
class boxes.edges.Edge(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

Straight edge

char = 'e'
description = 'Straight Edge'
positive = False
class boxes.edges.FingerHoleEdge(boxes, fingerHoles=None, **kw)[source]

Bases: boxes.edges.BaseEdge

Edge with holes for a parallel finger joint

char = 'h'
description = 'Edge (parallel Finger Joint Holes)'
startwidth()[source]
class boxes.edges.FingerHoles(boxes, settings)[source]

Bases: boxes.edges.FingerJointBase

Hole matching a finger joint edge

class boxes.edges.FingerJointBase[source]

Bases: object

calcFingers(length, bedBolts)[source]
fingerLength(angle)[source]
class boxes.edges.FingerJointEdge(boxes, settings)[source]

Bases: boxes.edges.BaseEdge, boxes.edges.FingerJointBase

Finger joint edge

char = 'f'
description = 'Finger Joint'
margin()[source]
positive = True
startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.FingerJointEdgeCounterPart(boxes, settings)[source]

Bases: boxes.edges.FingerJointEdge

Finger joint edge - other side

char = 'F'
description = 'Finger Joint (opposing side)'
positive = False
class boxes.edges.FingerJointSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for Finger Joints

Values:

  • absolute * style : “rectangular” : style of the fingers * surroundingspaces : 2 : maximum space at the start and end in multiple of normal spaces * angle: 90 : Angle of the walls meeting

  • relative (in multiples of thickness)

    • space : 2.0 : space between fingers

    • finger : 2.0 : width of the fingers

    • width : 1.0 : width of finger holes

    • edge_width : 1.0 : space below holes of FingerHoleEdge

    • play : 0.0 : extra space to allow finger move in and out

absolute_params = {'angle': 90.0, 'style': ('rectangular', 'springs'), 'surroundingspaces': 2.0}
checkValues()[source]

Check if all values are in the right range. Raise ValueError if needed

edgeObjects(boxes, chars='fFh', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'edge_width': 1.0, 'finger': 2.0, 'play': 0.0, 'space': 2.0, 'width': 1.0}
class boxes.edges.FlexEdge(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

Edge with flex cuts - use straight edge for the opposing side

char = 'X'
description = 'Flex cut'
class boxes.edges.FlexSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for Flex

Values:

  • absolute

  • stretch : 1.05 : Hint of how much the flex part should be shortend

  • relative (in multiples of thickness)

  • distance : 0.5 : width of the pattern perpendicular to the cuts

  • connection : 1.0 : width of the gaps in the cuts

  • width” : 5.0 : width of the pattern in direction of the cuts

absolute_params = {'stretch': 1.05}
checkValues()[source]

Check if all values are in the right range. Raise ValueError if needed

relative_params = {'connection': 1.0, 'distance': 0.5, 'width': 5.0}
class boxes.edges.GearSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for rack (and pinion) edge Values: * absolute_params

  • dimension : 3.0 : modulus of the gear (in mm)

  • angle : 20.0 : pressure angle

  • profile_shift : 20.0 : Profile shift

  • clearance : 0.0 : clearance

absolute_params = {'angle': 20.0, 'clearance': 0.0, 'dimension': 3.0, 'profile_shift': 20.0}
relative_params = {}
class boxes.edges.GripSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for GrippingEdge Values:

  • absolute_params

  • style : “wave : “wave” or “bumps”

  • outset : True : extend outward the straight edge

  • relative (in multiples of thickness)

  • depth : 0.3 : depth of the grooves

absolute_params = {'outset': True, 'style': ('wave', 'bumps')}
edgeObjects(boxes, chars='g', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'depth': 0.3}
class boxes.edges.GrippingEdge(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

bumps(length)[source]
char = 'g'
description = 'Corrugated edge useful as an gipping area'
margin()[source]

Space needed right of the starting point

wave(length)[source]
class boxes.edges.Hinge(boxes, settings=None, layout=1)[source]

Bases: boxes.edges.BaseEdge

char = 'i'
description = 'Straight edge with hinge eye'
flush(_reversed=False)[source]
flushlen()[source]
margin()[source]

Space needed right of the starting point

outset(_reversed=False)[source]
outsetlen()[source]
class boxes.edges.HingePin(boxes, settings=None, layout=1)[source]

Bases: boxes.edges.BaseEdge

char = 'I'
description = 'Edge with hinge pin'
endwidth()[source]
flush(_reversed=False)[source]
flushlen()[source]
margin()[source]

Space needed right of the starting point

outset(_reversed=False)[source]
outsetlen()[source]
startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.HingeSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for Hinges and HingePins Values:

  • absolute_params

  • style : “outset” : “outset” or “flush”

  • outset : False : have lid overlap at the sides (similar to OutSetEdge)

  • pinwidth : 1.0 : set to lower value to get disks surrounding the pins

  • grip_percentage” : 0 : percentage of the lid that should get grips

  • relative (in multiples of thickness)

  • hingestrength : 1 : thickness of the arc holding the pin in place

  • axle : 2 : diameter of the pin hole

  • grip_length : 0 : fixed length of the grips on he lids

absolute_params = {'grip_percentage': 0, 'outset': False, 'pinwidth': 0.5, 'style': ('outset', 'flush')}
edgeObjects(boxes, chars='iIjJkK', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'axle': 2, 'grip_length': 0, 'hingestrength': 1}
class boxes.edges.LidEdge(boxes, settings)[source]

Bases: boxes.edges.FingerJointEdge

char = 'l'
description = 'Edge for slide on lid (back)'
class boxes.edges.LidHoleEdge(boxes, fingerHoles=None, **kw)[source]

Bases: boxes.edges.FingerHoleEdge

char = 'L'
description = 'Edge for slide on lid (box back)'
class boxes.edges.LidLeft(boxes, settings)[source]

Bases: boxes.edges.LidRight

char = 'm'
description = 'Edge for slide on lid (left)'
rightside = False
class boxes.edges.LidRight(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

char = 'n'
description = 'Edge for slide on lid (right)'
endwidth()[source]
margin()[source]

Space needed right of the starting point

rightside = True
startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.LidSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.FingerJointSettings

Settings for Slide-on Lids

Note that edge_width below also determines how much the sides extend above the lid.

Inherited:

Settings for Finger Joints

Values:

  • absolute * style : “rectangular” : style of the fingers * surroundingspaces : 2 : maximum space at the start and end in multiple of normal spaces * angle: 90 : Angle of the walls meeting

  • relative (in multiples of thickness)

    • space : 2.0 : space between fingers

    • finger : 2.0 : width of the fingers

    • width : 1.0 : width of finger holes

    • edge_width : 1.0 : space below holes of FingerHoleEdge

    • play : 0.0 : extra space to allow finger move in and out

absolute_params = {'angle': 90.0, 'second_pin': True, 'spring': ('both', 'none', 'left', 'right'), 'style': ('rectangular', 'springs'), 'surroundingspaces': 2.0}
edgeObjects(boxes, chars=None, add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'edge_width': 1.0, 'finger': 3.0, 'play': 0.05, 'space': 2.0, 'width': 1.0}
class boxes.edges.LidSideLeft(boxes, settings)[source]

Bases: boxes.edges.LidSideRight

char = 'M'
description = 'Edge for slide on lid (box left)'
rightside = False
class boxes.edges.LidSideRight(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

char = 'N'
description = 'Edge for slide on lid (box right)'
endwidth()[source]
margin()[source]

Space needed right of the starting point

rightside = True
startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.OutSetEdge(boxes, settings)[source]

Bases: boxes.edges.Edge

Straight edge out set by one thickness

char = 'E'
description = 'Straight Edge (outset by thickness)'
positive = True
startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.RackEdge(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

char = 'R'
description = 'Rack (and pinion) Edge'
margin()[source]

Space needed right of the starting point

class boxes.edges.RoundedTriangleEdge(boxes, settings)[source]

Bases: boxes.edges.Edge

Makes an ‘edge’ with a rounded triangular bumpout and optional hole

char = 't'
description = 'Triangle for handle'
margin()[source]

Space needed right of the starting point

class boxes.edges.RoundedTriangleEdgeSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for RoundedTriangleEdge Values:

  • absolute_params

  • height : 150. : height above the wall

  • radius : 30. : radius of top corner

  • r_hole : 0. : radius of hole

  • relative (in multiples of thickness)

  • outset : 0 : extend the triangle along the length of the edge

absolute_params = {'height': 150.0, 'r_hole': 2.0, 'radius': 30.0}
edgeObjects(boxes, chars='t', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'outset': 0.0}
class boxes.edges.Settings(thickness, relative=True, **kw)[source]

Bases: object

Generic Settings class

Used by different other classes to store messurements and details. Supports absolute values and settings that grow with the thickness of the material used.

Overload the absolute_params and relative_params class attributes with the suported keys and default values. The values are available via attribute access.

absolute_params = {}
checkValues()[source]

Check if all values are in the right range. Raise ValueError if needed

edgeObjects(boxes, chars='', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

classmethod parserArguments(parser, prefix=None, **defaults)[source]
relative_params = {}
setValues(thickness, relative=True, **kw)[source]

Set values

Parameters
  • thickness – thickness of the material used

  • relative – (Default value = True) Do scale by thickness

  • **kw – parameters to set

class boxes.edges.SlatWallBackEdge(boxes, settings)[source]

Bases: boxes.edges.SlatWallEdge

char = 'c'
margin()[source]

Space needed right of the starting point

class boxes.edges.SlatWallBackEdgeReversed(boxes, settings)[source]

Bases: boxes.edges.SlatWallBackEdge

char = 'C'
reversed_ = True
class boxes.edges.SlatWallEdge(boxes, settings)[source]

Bases: boxes.edges.BaseEdge

char = 'a'
margin()[source]

Space needed right of the starting point

reversed_ = False
class boxes.edges.SlatWallEdgeReversed(boxes, settings)[source]

Bases: boxes.edges.SlatWallEdge

char = 'A'
reversed_ = True
class boxes.edges.SlatWallHoleEdge(boxes, slatWallHoles=None, **kw)[source]

Bases: boxes.edges.BaseEdge

Edge with holes for a parallel finger joint

char = 'd'
description = 'Edge (parallel slot wall Holes)'
reversed_ = False
startwidth()[source]
class boxes.edges.SlatWallHoleEdgeReversed(boxes, slatWallHoles=None, **kw)[source]

Bases: boxes.edges.SlatWallHoleEdge

char = 'D'
reversed_ = True
class boxes.edges.SlatWallHoles(boxes, settings)[source]

Bases: boxes.edges.SlatWallEdge

reversed_ = True
class boxes.edges.SlatWallJoinedEdge(boxes, settings)[source]

Bases: boxes.edges.SlatWallEdge

char = 'b'
startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.SlatWallJoinedEdgeReversed(boxes, settings)[source]

Bases: boxes.edges.SlatWallJoinedEdge

char = 'B'
reversed_ = True
class boxes.edges.SlatWallSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for SlatWallEdges Values:

  • absolute_params

  • bottom_hook : “hook” : “spring”, “stud” or “none”

  • relative (in multiples of thickness)

  • hook_extra_height : 2.0 : space surrounding connectors (in multiples of thickness)

  • edge_width : 1.0 : space below holes of FingerHoleEdge

absolute_params = {'bottom_hook': ('hook', 'spring', 'stud', 'none')}
edgeObjects(boxes, chars='aAbBcCdD', add=True)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'edge_width': 1.0, 'hook_extra_height': 2.0}
class boxes.edges.Slot(boxes, depth)[source]

Bases: boxes.edges.BaseEdge

Edge with an slot to slid another pice through

description = 'Slot'
class boxes.edges.SlottedEdge(boxes, sections, edge='e', slots=0)[source]

Bases: boxes.edges.BaseEdge

Edge with multiple slots

description = 'Straight Edge with slots'
endwidth()[source]
margin()[source]

Space needed right of the starting point

startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.StackableEdge(boxes, settings, fingerjointsettings)[source]

Bases: boxes.edges.BaseEdge

Edge for having stackable Boxes. The Edge creates feet on the bottom and has matching recesses on the top corners.

bottom = True
char = 's'
description = 'Stackable (bottom, finger joint holes)'
margin()[source]

Space needed right of the starting point

startwidth()[source]

Amount of space the beginning of the edge is set below the inner space of the part

class boxes.edges.StackableEdgeTop(boxes, settings, fingerjointsettings)[source]

Bases: boxes.edges.StackableEdge

bottom = False
char = 'S'
description = 'Stackable (top)'
class boxes.edges.StackableSettings(thickness, relative=True, **kw)[source]

Bases: boxes.edges.Settings

Settings for Stackable Edges

Values:

  • absolute_params

    • angle : 60 : inside angle of the feet

  • relative (in multiples of thickness)

    • height : 2.0 : height of the feet

    • width : 4.0 : width of the feet

    • holedistance : 1.0 : distance from finger holes to bottom edge

absolute_params = {'angle': 60}
checkValues()[source]

Check if all values are in the right range. Raise ValueError if needed

edgeObjects(boxes, chars='sS', add=True, fingersettings=None)[source]

Generate Edge objects using this kind of settings

Parameters
  • boxes – Boxes object

  • chars – sequence of chars to be used by Edge objects

  • add – add the resulting Edge objects to the Boxes object’s edges

relative_params = {'height': 2.0, 'holedistance': 1.0, 'width': 4.0}
boxes.edges.getDescriptions()[source]

boxes.formats module

class boxes.formats.Formats[source]

Bases: object

convert(filename, fmt, metadata=None)[source]
formats = {'ai': ['-f', 'ps2ai'], 'dxf': ['-flat', '0.1', '-f', 'dxf:-mm'], 'gcode': ['-f', 'gcode'], 'pdf': ['-f', 'pdf'], 'plt': ['-f', 'plot-hpgl'], 'ps': None, 'svg': None, 'svg_Ponoko': None}
getFormats()[source]
getSurface(fmt, filename)[source]
http_headers = {'dxf': [('Content-type', 'image/vnd.dxf')], 'gcode': [('Content-type', 'text/plain; charset=utf-8')], 'plt': [('Content-type', ' application/vnd.hp-hpgl')], 'ps': [('Content-type', 'application/postscript')], 'svg': [('Content-type', 'image/svg+xml; charset=utf-8')], 'svg_Ponoko': [('Content-type', 'image/svg+xml; charset=utf-8')]}
pstoedit = '/usr/bin/pstoedit'
class boxes.formats.PSFile(filename)[source]

Bases: object

adjustDocumentMedia()[source]

boxes.gears module

class boxes.gears.Gears(boxes, **kw)[source]

Bases: object

calc_circular_pitch()[source]

We use math based on circular pitch.

drawPoints(lines, kerfdir=1, close=True)[source]
gearCarrier(r, spoke_width, positions, mount_radius, mount_hole, circle=True, callback=None, move=None)[source]
generate_spokes(root_radius, spoke_width, spokes, mount_radius, mount_hole, unit_factor, unit_label)[source]

given a set of constraints - generate the svg path for the gear spokes - lies between mount_radius (inner hole) and root_radius (bottom of the teeth) - spoke width also defines the spacing at the root_radius - mount_radius is adjusted so that spokes fit if there is room - if no room (collision) then spokes not drawn

sizes(**kw)[source]
class boxes.gears.OptionParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)[source]

Bases: argparse.ArgumentParser

add_option(short, long_, **kw)[source]
types = {'float': <class 'float'>, 'inkbool': <function inkbool>, 'int': <class 'int'>, 'string': <class 'str'>}
boxes.gears.gear_calculations(num_teeth, circular_pitch, pressure_angle, clearance=0, ring_gear=False, profile_shift=0.0)[source]

Put base calcs for spur/ring gears in one place. - negative profile shifting helps against undercut.

boxes.gears.generate_rack_points(tooth_count, pitch, addendum, pressure_angle, base_height, tab_length, clearance=0, draw_guides=False)[source]

Return path (suitable for svg) of the Rack gear. - rack gear uses straight sides

  • involute on a circle of infinite radius is a simple linear ramp

  • the meshing circle touches at y = 0,

  • the highest elevation of the teeth is at y = +addendum

  • the lowest elevation of the teeth is at y = -addendum-clearance

  • the base_height extends downwards from the lowest elevation.

  • we generate this middle tooth exactly centered on the y=0 line. (one extra tooth on the right hand side, if number of teeth is even)

boxes.gears.generate_spur_points(teeth, base_radius, pitch_radius, outer_radius, root_radius, accuracy_involute, accuracy_circular)[source]

given a set of core gear params - generate the svg path for the gear

boxes.gears.have_undercut(teeth, pitch_angle=20.0, k=1.0)[source]

returns true if the specified number of teeth would cause an undercut.

boxes.gears.inkbool(val)[source]
boxes.gears.involute_intersect_angle(Rb, R)[source]
boxes.gears.linspace(a, b, n)[source]

return list of linear interp of a to b in n steps - if a and b are ints - you’ll get an int result. - n must be an integer

boxes.gears.point_on_circle(radius, angle)[source]

return xy coord of the point at distance radius from origin at angle

boxes.gears.undercut_max_k(teeth, pitch_angle=20.0)[source]

computes the maximum k value for a given teeth count and pitch_angle so that no undercut occurs.

boxes.gears.undercut_min_angle(teeth, k=1.0)[source]

computes the minimum pitch angle, to that the given teeth count (and profile shift) cause no undercut.

boxes.gears.undercut_min_teeth(pitch_angle, k=1.0)[source]

computes the minimum tooth count for a spur gear so that no undercut with the given pitch_angle (in deg) and an addendum = k * metric_module, where 0 < k < 1

Note: The return value should be rounded upwards for perfect safety. E.g. min_teeth = int(math.ceil(undercut_min_teeth(20.0))) # 18, not 17

boxes.lids module

boxes.mounts module

boxes.parts module

class boxes.parts.Parts(boxes)[source]

Bases: object

concaveKnob(diameter, n=3, rounded=0.2, angle=70, hole=0, callback=None, move='')[source]

Knob with dents to be easier to be gripped

Parameters
  • diameter – diameter of the knob

  • n – (Default value = 3) number of dents

  • rounded – (Default value = 0.2) proportion of circumferen remaining

  • angle – (Default value = 70) angle the dents meet the circumference

  • hole – (Default value = 0)

  • callback – (Default value = None) called in the center

  • move – (Defaultvalue = None)

disc(diameter, hole=0, callback=None, move='')[source]

Simple disc

Parameters
  • diameter – diameter of the disc

  • hole – (Default value = 0)

  • callback – (Default value = None) called in the center

  • move – (Defaultvalue = None)

ringSegment(r_outside, r_inside, angle, n=1, move=None)[source]

Ring Segment

Parameters
  • r_outside – outer radius

  • r_inside – inner radius

  • angle – anlge the segment is spanning

  • n – (Default value = 1) number of segments

  • move – (Defaultvalue = None)

waivyKnob(diameter, n=20, angle=45, hole=0, callback=None, move='')[source]

Disc with a waivy edge to be easier to be gripped

Parameters
  • diameter – diameter of the knob

  • n – (Default value = 20) number of waves

  • angle – (Default value = 45) maximum angle of the wave

  • hole – (Default value = 0)

  • callback – (Default value = None) called in the center

  • move – (Defaultvalue = None)

boxes.parts.arcOnCircle(spanning_angle, outgoing_angle, r=1.0)[source]

boxes.pulley module

// Parametric Pulley with multiple belt profiles // by droftarts January 2012

// Based on pulleys by: // http://www.thingiverse.com/thing:11256 by me! // https://github.com/prusajr/PrusaMendel by Josef Prusa // http://www.thingiverse.com/thing:3104 by GilesBathgate // http://www.thingiverse.com/thing:2079 by nophead

// dxf tooth data from http://oem.cadregister.com/asp/PPOW_Entry.asp?company=915217&elementID=07807803/METRIC/URETH/WV0025/F // pulley diameter checked and modelled from data at http://www.sdp-si.com/D265/HTML/D265T016.html

class boxes.pulley.Pulley(boxes)[source]

Bases: object

diameter(teeth, profile)[source]
drawPoints(lines, kerfdir=1)[source]
classmethod getProfiles()[source]
profile_data = {'40DP': (0.457, 1.226), 'AT5': (1.19, 4.268), 'GT2_2mm': (0.764, 1.494), 'GT2_3mm': (1.169, 2.31), 'GT2_5mm': (1.969, 3.952), 'H': (1.905, 5.359), 'HTD_3mm': (1.289, 2.27), 'HTD_5mm': (2.199, 3.781), 'HTD_8mm': (3.607, 6.603), 'MXL': (0.508, 1.321), 'T10': (2.5, 6.13), 'T2_5': (0.7, 1.678), 'T5': (1.19, 3.264), 'XL': (1.27, 3.051)}
spacing = {'40DP': (False, 2.07264, 0.1778), 'AT5': (True, 0.6523, 1.591, 1.064), 'GT2_2mm': (False, 2, 0.254), 'GT2_3mm': (False, 3, 0.381), 'GT2_5mm': (False, 5, 0.5715), 'H': (False, 9.525, 0.381), 'HTD_3mm': (False, 3, 0.381), 'HTD_5mm': (False, 5, 0.5715), 'HTD_8mm': (False, 8, 0.6858), 'MXL': (False, 2.032, 0.254), 'T10': (False, 10, 0.93), 'T2_5': (True, 0.7467, 0.796, 1.026), 'T5': (True, 0.6523, 1.591, 1.064), 'XL': (False, 5.08, 0.254)}
teeth = {'40DP': [[-0.612775, -0.5], [-0.612775, 0], [-0.574719, 0.010187], [-0.546453, 0.0381], [-0.355953, 0.3683], [-0.327604, 0.405408], [-0.291086, 0.433388], [-0.248548, 0.451049], [-0.202142, 0.4572], [0.202494, 0.4572], [0.248653, 0.451049], [0.291042, 0.433388], [0.327609, 0.405408], [0.356306, 0.3683], [0.546806, 0.0381], [0.574499, 0.010187], [0.612775, 0], [0.612775, -0.5]], 'AT5': [[-2.134129, -0.75], [-2.134129, 0], [-2.058023, 0.005488], [-1.984595, 0.021547], [-1.914806, 0.047569], [-1.849614, 0.082947], [-1.789978, 0.127073], [-1.736857, 0.179338], [-1.691211, 0.239136], [-1.653999, 0.305859], [-1.349199, 0.959203], [-1.286933, 1.054635], [-1.201914, 1.127346], [-1.099961, 1.173664], [-0.986896, 1.18992], [0.986543, 1.18992], [1.099614, 1.173664], [1.201605, 1.127346], [1.286729, 1.054635], [1.349199, 0.959203], [1.653646, 0.305859], [1.690859, 0.239136], [1.73651, 0.179338], [1.789644, 0.127073], [1.849305, 0.082947], [1.914539, 0.047569], [1.984392, 0.021547], [2.057906, 0.005488], [2.134129, 0], [2.134129, -0.75]], 'GT2_2mm': [[-0.747183, -0.5], [-0.747183, 0], [-0.647876, 0.037218], [-0.598311, 0.130528], [-0.578556, 0.238423], [-0.547158, 0.343077], [-0.504649, 0.443762], [-0.451556, 0.53975], [-0.358229, 0.636924], [-0.2484, 0.707276], [-0.127259, 0.750044], [0, 0.76447], [0.127259, 0.750044], [0.2484, 0.707276], [0.358229, 0.636924], [0.451556, 0.53975], [0.504797, 0.443762], [0.547291, 0.343077], [0.578605, 0.238423], [0.598311, 0.130528], [0.648009, 0.037218], [0.747183, 0], [0.747183, -0.5]], 'GT2_3mm': [[-1.155171, -0.5], [-1.155171, 0], [-1.065317, 0.016448], [-0.989057, 0.062001], [-0.93297, 0.130969], [-0.90364, 0.217664], [-0.863705, 0.408181], [-0.800056, 0.591388], [-0.713587, 0.765004], [-0.60519, 0.926747], [-0.469751, 1.032548], [-0.320719, 1.108119], [-0.162625, 1.153462], [0, 1.168577], [0.162625, 1.153462], [0.320719, 1.108119], [0.469751, 1.032548], [0.60519, 0.926747], [0.713587, 0.765004], [0.800056, 0.591388], [0.863705, 0.408181], [0.90364, 0.217664], [0.932921, 0.130969], [0.988924, 0.062001], [1.065168, 0.016448], [1.155171, 0], [1.155171, -0.5]], 'GT2_5mm': [[-1.975908, -0.75], [-1.975908, 0], [-1.797959, 0.03212], [-1.646634, 0.121224], [-1.534534, 0.256431], [-1.474258, 0.426861], [-1.446911, 0.570808], [-1.411774, 0.712722], [-1.368964, 0.852287], [-1.318597, 0.989189], [-1.260788, 1.123115], [-1.195654, 1.25375], [-1.12331, 1.380781], [-1.043869, 1.503892], [-0.935264, 1.612278], [-0.817959, 1.706414], [-0.693181, 1.786237], [-0.562151, 1.851687], [-0.426095, 1.9027], [-0.286235, 1.939214], [-0.143795, 1.961168], [0, 1.9685], [0.143796, 1.961168], [0.286235, 1.939214], [0.426095, 1.9027], [0.562151, 1.851687], [0.693181, 1.786237], [0.817959, 1.706414], [0.935263, 1.612278], [1.043869, 1.503892], [1.123207, 1.380781], [1.195509, 1.25375], [1.26065, 1.123115], [1.318507, 0.989189], [1.368956, 0.852287], [1.411872, 0.712722], [1.447132, 0.570808], [1.474611, 0.426861], [1.534583, 0.256431], [1.646678, 0.121223], [1.798064, 0.03212], [1.975908, 0], [1.975908, -0.75]], 'H': [[-2.6797, -1], [-2.6797, 0], [-2.600907, 0.006138], [-2.525342, 0.024024], [-2.45412, 0.052881], [-2.388351, 0.091909], [-2.329145, 0.140328], [-2.277614, 0.197358], [-2.234875, 0.262205], [-2.202032, 0.334091], [-1.75224, 1.57093], [-1.719538, 1.642815], [-1.676883, 1.707663], [-1.62542, 1.764693], [-1.566256, 1.813112], [-1.500512, 1.85214], [-1.4293, 1.880997], [-1.353742, 1.898883], [-1.274949, 1.905021], [1.275281, 1.905021], [1.354056, 1.898883], [1.429576, 1.880997], [1.500731, 1.85214], [1.566411, 1.813112], [1.625508, 1.764693], [1.676919, 1.707663], [1.719531, 1.642815], [1.752233, 1.57093], [2.20273, 0.334091], [2.235433, 0.262205], [2.278045, 0.197358], [2.329455, 0.140328], [2.388553, 0.091909], [2.454233, 0.052881], [2.525384, 0.024024], [2.600904, 0.006138], [2.6797, 0], [2.6797, -1]], 'HTD_3mm': [[-1.135062, -0.5], [-1.135062, 0], [-1.048323, 0.015484], [-0.974284, 0.058517], [-0.919162, 0.123974], [-0.889176, 0.206728], [-0.81721, 0.579614], [-0.800806, 0.653232], [-0.778384, 0.72416], [-0.750244, 0.792137], [-0.716685, 0.856903], [-0.678005, 0.918199], [-0.634505, 0.975764], [-0.586483, 1.029338], [-0.534238, 1.078662], [-0.47807, 1.123476], [-0.418278, 1.16352], [-0.355162, 1.198533], [-0.289019, 1.228257], [-0.22015, 1.25243], [-0.148854, 1.270793], [-0.07543, 1.283087], [-0.000176, 1.28905], [0.075081, 1.283145], [0.148515, 1.270895], [0.219827, 1.252561], [0.288716, 1.228406], [0.354879, 1.19869], [0.418018, 1.163675], [0.477831, 1.123623], [0.534017, 1.078795], [0.586276, 1.029452], [0.634307, 0.975857], [0.677809, 0.91827], [0.716481, 0.856953], [0.750022, 0.792167], [0.778133, 0.724174], [0.800511, 0.653236], [0.816857, 0.579614], [0.888471, 0.206728], [0.919014, 0.123974], [0.974328, 0.058517], [1.048362, 0.015484], [1.135062, 0], [1.135062, -0.5]], 'HTD_5mm': [[-1.89036, -0.75], [-1.89036, 0], [-1.741168, 0.02669], [-1.61387, 0.100806], [-1.518984, 0.21342], [-1.467026, 0.3556], [-1.427162, 0.960967], [-1.398568, 1.089602], [-1.359437, 1.213531], [-1.310296, 1.332296], [-1.251672, 1.445441], [-1.184092, 1.552509], [-1.108081, 1.653042], [-1.024167, 1.746585], [-0.932877, 1.832681], [-0.834736, 1.910872], [-0.730271, 1.980701], [-0.62001, 2.041713], [-0.504478, 2.09345], [-0.384202, 2.135455], [-0.259708, 2.167271], [-0.131524, 2.188443], [-0.000176, 2.198511], [0.131296, 2.188504], [0.259588, 2.167387], [0.384174, 2.135616], [0.504527, 2.093648], [0.620123, 2.04194], [0.730433, 1.980949], [0.834934, 1.911132], [0.933097, 1.832945], [1.024398, 1.746846], [1.108311, 1.653291], [1.184308, 1.552736], [1.251865, 1.445639], [1.310455, 1.332457], [1.359552, 1.213647], [1.39863, 1.089664], [1.427162, 0.960967], [1.467026, 0.3556], [1.518984, 0.21342], [1.61387, 0.100806], [1.741168, 0.02669], [1.89036, 0], [1.89036, -0.75]], 'HTD_8mm': [[-3.301471, -1], [-3.301471, 0], [-3.16611, 0.012093], [-3.038062, 0.047068], [-2.919646, 0.10297], [-2.813182, 0.177844], [-2.720989, 0.269734], [-2.645387, 0.376684], [-2.588694, 0.496739], [-2.553229, 0.627944], [-2.460801, 1.470025], [-2.411413, 1.691917], [-2.343887, 1.905691], [-2.259126, 2.110563], [-2.158035, 2.30575], [-2.041518, 2.490467], [-1.910478, 2.66393], [-1.76582, 2.825356], [-1.608446, 2.973961], [-1.439261, 3.10896], [-1.259169, 3.22957], [-1.069074, 3.335006], [-0.869878, 3.424485], [-0.662487, 3.497224], [-0.447804, 3.552437], [-0.226732, 3.589341], [-0.000176, 3.607153], [0.226511, 3.589461], [0.447712, 3.552654], [0.66252, 3.497516], [0.870027, 3.424833], [1.069329, 3.33539], [1.259517, 3.229973], [1.439687, 3.109367], [1.608931, 2.974358], [1.766344, 2.825731], [1.911018, 2.664271], [2.042047, 2.490765], [2.158526, 2.305998], [2.259547, 2.110755], [2.344204, 1.905821], [2.411591, 1.691983], [2.460801, 1.470025], [2.553229, 0.627944], [2.588592, 0.496739], [2.645238, 0.376684], [2.720834, 0.269734], [2.81305, 0.177844], [2.919553, 0.10297], [3.038012, 0.047068], [3.166095, 0.012093], [3.301471, 0], [3.301471, -1]], 'MXL': [[-0.660421, -0.5], [-0.660421, 0], [-0.621898, 0.006033], [-0.587714, 0.023037], [-0.560056, 0.049424], [-0.541182, 0.083609], [-0.417357, 0.424392], [-0.398413, 0.458752], [-0.370649, 0.48514], [-0.336324, 0.502074], [-0.297744, 0.508035], [0.297744, 0.508035], [0.336268, 0.502074], [0.370452, 0.48514], [0.39811, 0.458752], [0.416983, 0.424392], [0.540808, 0.083609], [0.559752, 0.049424], [0.587516, 0.023037], [0.621841, 0.006033], [0.660421, 0], [0.660421, -0.5]], 'T10': [[-3.06511, -1], [-3.06511, 0], [-2.971998, 0.007239], [-2.882718, 0.028344], [-2.79859, 0.062396], [-2.720931, 0.108479], [-2.651061, 0.165675], [-2.590298, 0.233065], [-2.539962, 0.309732], [-2.501371, 0.394759], [-1.879071, 2.105025], [-1.840363, 2.190052], [-1.789939, 2.266719], [-1.729114, 2.334109], [-1.659202, 2.391304], [-1.581518, 2.437387], [-1.497376, 2.47144], [-1.408092, 2.492545], [-1.314979, 2.499784], [1.314979, 2.499784], [1.408091, 2.492545], [1.497371, 2.47144], [1.581499, 2.437387], [1.659158, 2.391304], [1.729028, 2.334109], [1.789791, 2.266719], [1.840127, 2.190052], [1.878718, 2.105025], [2.501018, 0.394759], [2.539726, 0.309732], [2.59015, 0.233065], [2.650975, 0.165675], [2.720887, 0.108479], [2.798571, 0.062396], [2.882713, 0.028344], [2.971997, 0.007239], [3.06511, 0], [3.06511, -1]], 'T2_5': [[-0.839258, -0.5], [-0.839258, 0], [-0.770246, 0.021652], [-0.726369, 0.079022], [-0.529167, 0.620889], [-0.485025, 0.67826], [-0.416278, 0.699911], [0.416278, 0.699911], [0.484849, 0.67826], [0.528814, 0.620889], [0.726369, 0.079022], [0.770114, 0.021652], [0.839258, 0], [0.839258, -0.5]], 'T5': [[-1.632126, -0.5], [-1.632126, 0], [-1.568549, 0.004939], [-1.507539, 0.019367], [-1.450023, 0.042686], [-1.396912, 0.074224], [-1.349125, 0.113379], [-1.307581, 0.159508], [-1.273186, 0.211991], [-1.246868, 0.270192], [-1.009802, 0.920362], [-0.983414, 0.978433], [-0.949018, 1.030788], [-0.907524, 1.076798], [-0.859829, 1.115847], [-0.80682, 1.147314], [-0.749402, 1.170562], [-0.688471, 1.184956], [-0.624921, 1.189895], [0.624971, 1.189895], [0.688622, 1.184956], [0.749607, 1.170562], [0.807043, 1.147314], [0.860055, 1.115847], [0.907754, 1.076798], [0.949269, 1.030788], [0.9837, 0.978433], [1.010193, 0.920362], [1.246907, 0.270192], [1.273295, 0.211991], [1.307726, 0.159508], [1.349276, 0.113379], [1.397039, 0.074224], [1.450111, 0.042686], [1.507589, 0.019367], [1.568563, 0.004939], [1.632126, 0], [1.632126, -0.5]], 'XL': [[-1.525411, -1], [-1.525411, 0], [-1.41777, 0.015495], [-1.320712, 0.059664], [-1.239661, 0.129034], [-1.180042, 0.220133], [-0.793044, 1.050219], [-0.733574, 1.141021], [-0.652507, 1.210425], [-0.555366, 1.254759], [-0.447675, 1.270353], [0.447675, 1.270353], [0.555366, 1.254759], [0.652507, 1.210425], [0.733574, 1.141021], [0.793044, 1.050219], [1.180042, 0.220133], [1.239711, 0.129034], [1.320844, 0.059664], [1.417919, 0.015495], [1.525411, 0], [1.525411, -1]]}
boxes.pulley.mirrorx(points)[source]
boxes.pulley.tooth_spaceing_curvefit(teeth, b, c, d)[source]
boxes.pulley.tooth_spacing(teeth, tooth_pitch, pitch_line_offset)[source]

boxes.robot module

class boxes.robot.RobotArg(includenone=False)[source]

Bases: object

choices()[source]
html(name, default)[source]
class boxes.robot.RobotArmMM(boxes, servo, servo2=None)[source]

Bases: boxes.robot._RobotArm

Robot arm segment with two parallel servos

class boxes.robot.RobotArmMm(boxes, servo, servo2=None)[source]

Bases: boxes.robot._RobotArm

Robot arm segment with two orthogonal servos

class boxes.robot.RobotArmUU(boxes, servo, servo2=None)[source]

Bases: boxes.robot._RobotArm

Robot arm segment with two parallel sets of hinge knuckles

class boxes.robot.RobotArmUu(boxes, servo, servo2=None)[source]

Bases: boxes.robot._RobotArm

Robot arm segment with two orthogonal sets of hinge knuckles

class boxes.robot.RobotArmMu(boxes, servo, servo2=None)[source]

Bases: boxes.robot._RobotArm

Robot arm segment with a servo and an orthogonal sets of hinge knuckles

boxes.servos module

class boxes.servos.EyeEdge(boxes, servo, fingerHoles=None, driven=False, outset=False, **kw)[source]

Bases: boxes.edges.FingerHoleEdge

char = 'm'
margin()[source]

Space needed right of the starting point

startwidth()[source]
class boxes.servos.Servo(boxes, axle=3)[source]

Bases: object

edges(edges)[source]
class boxes.servos.Servo9g(boxes, axle=3)[source]

Bases: boxes.servos.Servo

axle_pos = 6.0
bottom(x=0.0, y=0.0, angle=90.0)[source]
front(x=0.0, y=0.0, angle=90.0)[source]
height = 22.5
hinge_depth()[source]
hinge_width()[source]
length = 28.0
servo_axle = 4.6
top(x=0.0, y=0.0, angle=90.0)[source]
width = 12.0
class boxes.servos.Servo9gt(boxes, axle=3)[source]

Bases: boxes.servos.Servo9g

bottom(x=0.0, y=0.0, angle=90.0)[source]
front(x=0.0, y=0.0, angle=90.0)[source]
height = 35
top(x=0.0, y=0.0, angle=90.0)[source]
class boxes.servos.ServoArg(includenone=False)[source]

Bases: object

choices()[source]
html(name, default)[source]
boxes.servos.buildEdges(boxes, servo, chars='mMnN')[source]

boxes.svgutil module

class boxes.svgutil.Extend[source]

Bases: object

addExtend(extend, x, y)[source]
addPoint(x, y)[source]
class boxes.svgutil.SVGFile(filename)[source]

Bases: object

addMetadata(md)[source]
d = '(\\-?\\d+(\\.\\d+)?)'
fix(metadata=None)[source]
getEnvelope()[source]
getExtend(element, extend)[source]
moveOrigin()[source]
optimize(element)[source]
optimize_patterns = [(re.compile(' (\\-?\\d+(\\.\\d+)?) (\\-?\\d+(\\.\\d+)?) (M|L) \\1 \\3 '), ' \\1 \\3 '), (re.compile(' (\\-?\\d+(\\.\\d+)?) (\\-?\\d+(\\.\\d+)?) L (\\-?\\d+(\\.\\d+)?) \\3 '), ' \\1 \\3 H \\5 '), (re.compile(' (\\-?\\d+(\\.\\d+)?) (\\-?\\d+(\\.\\d+)?) L \\1 (\\-?\\d+(\\.\\d+)?) '), ' \\1 \\3 V \\5 '), (re.compile('H (\\-?\\d+(\\.\\d+)?) L \\1 (\\-?\\d+(\\.\\d+)?) '), 'H \\1 V \\3 '), (re.compile('V (\\-?\\d+(\\.\\d+)?) L (\\-?\\d+(\\.\\d+)?) \x01 '), 'V \\1 H \\3 ')]
pathre = re.compile('[MCL]? *((-?\\d+(\\.\\d+)?) (-?\\d+(\\.\\d+)?) *)+')
rewriteViewPort()[source]

Modify SVG file to have the correct width, height and viewPort attributes.

transformre = re.compile('matrix\\((-?\\d+(\\.\\d+)?),(-?\\d+(\\.\\d+)?),(-?\\d+(\\.\\d+)?),(-?\\d+(\\.\\d+)?),(-?\\d+(\\.\\d+)?),(-?\\d+(\\.\\d+)?)\\)')
boxes.svgutil.getSizeInMM(tree)[source]
boxes.svgutil.getViewBox(tree)[source]
boxes.svgutil.svgMerge(box, inkscape, output)[source]
boxes.svgutil.ticksPerMM(tree)[source]

boxes.vectors module

boxes.vectors.circlepoint(r, a)[source]
boxes.vectors.dotproduct(v1, v2)[source]

Dot product

boxes.vectors.kerf(points, k, closed=True)[source]

Outset points by k Assumes a closed loop of points

boxes.vectors.mmul(m0, m1)[source]
boxes.vectors.normalize(v)[source]

set lenght of vector to one

boxes.vectors.rotm(angle)[source]

Rotation matrix

boxes.vectors.tangent(x, y, r)[source]

angle and length of a tangent to a circle at x,y with raduis r

boxes.vectors.vadd(v1, v2)[source]

Sum of two vectors

boxes.vectors.vclip(v, length)[source]
boxes.vectors.vdiff(p1, p2)[source]

vector from point1 to point2

boxes.vectors.vlength(v)[source]
boxes.vectors.vorthogonal(v)[source]

orthogonal vector

boxes.vectors.vscalmul(v, a)[source]

scale vector by a

boxes.vectors.vtransl(v, m)[source]

Module contents

class boxes.ArgparseEdgeType(edges=None)[source]

Bases: object

argparse type to select from a set of edge types

edges = []
html(name, default)[source]
inx(name, viewname, arg)[source]
names = {'A': 'Abstract Edge Class', 'B': 'Abstract Edge Class', 'C': 'Abstract Edge Class', 'D': 'Edge (parallel slot wall Holes)', 'E': 'Straight Edge (outset by thickness)', 'F': 'Finger Joint (opposing side)', 'I': 'Edge with hinge pin', 'J': 'Edge with hinge pin (other end)', 'K': 'Edge with hinge pin (both ends)', 'L': 'Edge for slide on lid (box back)', 'M': 'Edge for slide on lid (box left)', 'N': 'Edge for slide on lid (box right)', 'O': 'Edge with chest hinge (other end)', 'P': 'Edge with chest hinge (other end)', 'Q': 'Edge opposing a chest hinge', 'R': 'Rack (and pinion) Edge', 'S': 'Stackable (top)', 'U': 'Edge with cabinet hinges top side', 'V': 'Edge with cabinet hinges 90° lid', 'X': 'Flex cut', 'a': 'Abstract Edge Class', 'b': 'Abstract Edge Class', 'c': 'Abstract Edge Class', 'd': 'Edge (parallel slot wall Holes)', 'e': 'Straight Edge', 'f': 'Finger Joint', 'g': 'Corrugated edge useful as an gipping area', 'h': 'Edge (parallel Finger Joint Holes)', 'i': 'Straight edge with hinge eye', 'j': 'Straight edge with hinge eye (other end)', 'k': 'Straight edge with hinge eye (both ends)', 'l': 'Edge for slide on lid (back)', 'm': 'Edge for slide on lid (left)', 'n': 'Edge for slide on lid (right)', 'o': 'Edge with chest hinge', 'p': 'Edge with chest hinge', 'q': 'Edge with pins for an chest hinge', 's': 'Stackable (bottom, finger joint holes)', 't': 'Triangle for handle', 'u': 'Edge with cabinet hinges', 'v': 'Edge with cabinet hinges for 90° lid', '|': 'Edge (orthogonal Finger Joint Holes)'}
class boxes.BoolArg[source]

Bases: object

html(name, default)[source]
class boxes.Boxes[source]

Bases: object

Main class – Generator should sub class this

NEMA(size, x=0, y=0, angle=0)[source]

Draw holes for mounting a NEMA stepper motor

Parameters
  • size – Nominal size in tenths of inches

  • x – (Default value = 0)

  • y – (Default value = 0)

  • angle – (Default value = 0)

TX(size, x=0, y=0, angle=0)[source]

Draw a star pattern

Parameters
  • size – 1 to 100

  • x – (Default value = 0)

  • y – (Default value = 0)

  • angle – (Default value = 0)

addPart(part, name=None)[source]

Add Edge or other part instance to this one and add it as attribute

Parameters
  • part – Callable

  • name – (Default value = None) attribute name (__name__ as default)

addParts(parts)[source]
addSettingsArgs(settings, prefix=None, **defaults)[source]
adjustSize(l, e1=True, e2=True)[source]
bedBoltHole(length, bedBoltSettings=None, tabs=0)[source]

Draw an edge with slot for a bed bolt

Parameters
  • length – length of the edge in mm

  • bedBoltSettings – (Default value = None) Dimmensions of the slot

buildArgParser(*l, **kw)[source]

Add commonly used arguments

Parameters
  • *l – parameter names

  • **kw – parameters with new default values

Supported parameters are

  • floats: x, y, h, hi

  • argparseSections: sx, sy, sh

  • ArgparseEdgeType: bottom_edge, top_edge

  • boolarg: outside

  • str (selection): nema_mount

cc(callback, number, x=0.0, y=None)[source]

Call callback from edge of a part

Parameters
  • 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)

circle(x, y, r)[source]

Draw a round disc

Parameters
  • x – position

  • y – postion

  • r – radius

close()[source]

Finish rendering

Flush canvas to disk and convert output to requested format if needed. Call after .render()

corner(degrees, radius=0, tabs=0)[source]

Draw a corner

This is what does the burn corrections

Parameters
  • degrees – angle

  • radius – (Default value = 0)

curveTo(x1, y1, x2, y2, x3, y3)[source]

control point 1, control point 2, end point

Parameters
  • x1

  • y1

  • x2

  • y2

  • x3

  • y3

dHole(x, y, r=None, d=None, w=None, rel_w=0.75, angle=0)[source]
description = ''
edge(length, tabs=0)[source]

Simple line :param length: length in mm

edgeCorner(edge1, edge2, angle=90)[source]

Make a corner between two Edges. Take width of edges into account

flangedWall(x, y, edges='FFFF', flanges=None, r=0.0, callback=None, move=None)[source]

Rectangular wall with flanges extending the regular size

This is similar to the rectangularWall but it may extend to either side replacing the F edge with fingerHoles. Use with E and F for edges only.

Parameters
  • x – width

  • y – height

  • edges – (Default value = “FFFF”) bottom, right, top, left

  • flanges – (Default value = None) list of width of the flanges

  • r – radius of the corners of the flange

  • callback – (Default value = None)

  • move – (Default value = None)

flatHole(x, y, r=None, d=None, w=None, rel_w=0.75, angle=0)[source]
flex2D(x, y, width=1)[source]

Fill a rectangle with a pattern allowing bending in both axis

Parameters
  • x – width

  • y – height

  • width – width between the lines of the pattern in multiples of thickness

getEntry(param, idx)[source]

Get entry from list or items itself

Parameters
  • param – list or item

  • idx – index in list

grip(length, depth)[source]

Corrugated edge useful as an gipping area

Parameters
  • length – length

  • depth – depth of the grooves

handle(x, h, hl, r=30)[source]

Creates an Edge with a handle

Parameters
  • x – width in mm

  • h – height in mm

  • hl – height if th grip hole

  • r – (Default value = 30) radius of the corners

hexHolesCircle(d, settings=None)[source]

Fill circle with holes in a hex pattern

Parameters
  • d – diameter of the circle

  • settings – (Default value = None)

hexHolesHex(h, settings=None, grow=None)[source]

Fill a hexagon with holes in a hex pattern

Parameters
  • h – height

  • settings – (Default value = None)

  • grow – (Default value = None)

hexHolesPlate(x, y, rc, settings=None)[source]

Fill a plate with holes in a hex pattern

Parameters
  • x – width

  • y – height

  • rc – radius of the corners

  • settings – (Default value = None)

hexHolesRectangle(x, y, settings=None, skip=None)[source]

Fills a rectangle with holes in a hex pattern.

Settings have: r : radius of holes b : space between holes style : what types of holes (not yet implemented)

Parameters
  • x – width

  • y – height

  • settings – (Default value = None)

  • skip – (Default value = None) function to check if hole should be present gets x, y, r, b, posx, posy

hole(x, y, r=0.0, d=0.0, tabs=0)[source]

Draw a round hole

Parameters
  • x – position

  • y – postion

  • r – radius

latch(length, positive=True, reverse=False)[source]

Latch to fix a flex box door to the box

Parameters
  • length – length in mm

  • positive – (Default value = True) False: Door side; True: Box side

  • reverse – (Default value = False) True when running away from the latch

mirrorX(f, offset=0.0)[source]

Wrap a function to draw mirrored at the y axis

Parameters
  • f – function to wrap

  • offset – (default value = 0.0) axis to mirror at

mirrorY(f, offset=0.0)[source]

Wrap a function to draw mirrored at the x axis

Parameters
  • f – function to wrap

  • offset – (default value = 0.0) axis to mirror at

move(x, y, where, before=False)[source]

Intended to be used by parts where can be combinations of “up” or “down”, “left” or “right”, “only”, “mirror” when “only” is included the move is only done when before is True “mirror” will flip the part along the y axis The function returns whether actual drawing of the part should be omited.

Parameters
  • x – width of part

  • y – height of part

  • where – which direction to move

  • before – (Default value = False) called before or after part being drawn

moveArc(angle, r=0.0)[source]
Parameters
  • angle

  • r – (Default value = 0.0)

moveTo(x, y=0.0, degrees=0)[source]

Move coordinate system to given point

Parameters
  • x

  • y – (Default value = 0.0)

  • degrees – (Default value = 0)

nema_sizes = {8: (20.3, 16, 15.4, 3), 11: (28.2, 22, 23, 4), 14: (35.2, 22, 26, 4), 16: (39.2, 22, 31, 4), 17: (42.2, 22, 31, 4), 23: (56.4, 38.1, 47.1, 5.2), 24: (60, 36, 49.8, 5.1), 34: (86.3, 73, 69.8, 6.6), 42: (110, 55.5, 89, 8.5)}
open()[source]

Prepare for rendering

Create canvas and edge and other objects Call this before .render()

parseArgs(args=None)[source]

Parse command line parameters

Parameters

args – (Default value = None) parameters, None for using sys.argv

partsMatrix(n, width, move, part, *l, **kw)[source]

place many of the same part

Parameters
  • 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

polygonWall(borders, edge='f', turtle=False, callback=None, move=None)[source]
polygonWalls(borders, h, bottom='F', top='F', symetrical=True)[source]
polyline(*args)[source]

Draw multiple connected lines

Parameters

*args – Alternating length in mm and angle in degrees.

lengths may be a tuple (length, #tabs) angles may be tuple (angle, radius)

rectangularHole(x, y, dx, dy, r=0)[source]

Draw an rectangulat hole

Parameters
  • x – position

  • y – position

  • dx – width

  • dy – height

  • r – (Default value = 0) radius of the corners

rectangularTriangle(x, y, edges='eee', r=0.0, num=1, bedBolts=None, bedBoltSettings=None, callback=None, move=None)[source]

Rectangular triangular wall

Parameters
  • x – width

  • y – height

  • edges – (Default value = “eee”) bottom, right[, diagonal]

  • r – radius towards the hypothenuse

  • num – (Default value = 1) number of triangles

  • bedBolts – (Default value = None)

  • bedBoltSettings – (Default value = None)

  • callback – (Default value = None)

  • move – (Default value = None)

rectangularWall(x, y, edges='eeee', ignore_widths=[], holesMargin=None, holesSettings=None, bedBolts=None, bedBoltSettings=None, callback=None, move=None)[source]

Rectangular wall for all kind of box like objects

Parameters
  • x – width

  • y – height

  • edges – (Default value = “eeee”) bottom, right, top, left

  • ignore_widths – list of edge_widths added to adjacent edge

  • holesMargin – (Default value = None)

  • holesSettings – (Default value = None)

  • bedBolts – (Default value = None)

  • bedBoltSettings – (Default value = None)

  • callback – (Default value = None)

  • move – (Default value = None)

regularPolygon(corners=3, radius=None, h=None, side=None)[source]

Give messures of a regular polygone

Parameters
  • corners – number of corners of the polygone

  • radius – distance center to one of the corners

  • h – distance center to one of the sides (height of sector)

  • side – length of one side

Returns

(radius, h, side)

regularPolygonAt(x, y, corners, angle=0, r=None, h=None, side=None)[source]

Draw regular polygone

regularPolygonWall(corners=3, r=None, h=None, side=None, edges='e', hole=None, callback=None, move=None)[source]

Create regular polygone as a wall

Parameters
  • corners – number of corners of the polygone

  • radius – distance center to one of the corners

  • h – distance center to one of the sides (height of sector)

  • side – length of one side

  • edges – (Default value = “e”, may be string/list of length corners)

  • hole – diameter of central hole (Default value = 0)

  • callback – (Default value = None, middle=0, then sides=1..)

  • move – (Default value = None)

render()[source]

Implement this method in your sub class.

You will typically need to call .parseArgs() before calling this one

roundedPlate(x, y, r, edge='f', callback=None, holesMargin=None, holesSettings=None, bedBolts=None, bedBoltSettings=None, wallpieces=1, extend_corners=True, move=None)[source]

Plate with rounded corner fitting to .surroundingWall()

For the callbacks the sides are counted depending on wallpieces

Parameters
  • x – width

  • y – hight

  • r – radius of the corners

  • callback – (Default value = None)

  • holesMargin – (Default value = None) set to get hex holes

  • holesSettings – (Default value = None)

  • bedBolts – (Default value = None)

  • bedBoltSettings – (Default value = None)

  • wallpieces – (Default value = 1) # of separate surrounding walls

  • extend_corners – (Default value = True) have corners outset with teh edges

  • move – (Default value = None)

saved_context()[source]

Generator: for saving and restoring cairo contexts. :param cr: cairo context

set_source_color(color)[source]

Sets the color of the pen.

step(out)[source]

Create a parallel step prependicular to the current direction Positive values move to the outside of the part

surroundingWall(x, y, r, h, bottom='e', top='e', left='D', right='d', pieces=1, extend_corners=True, callback=None, move=None)[source]

Wall(s) with flex fiting around a roundedPlate()

For the callbacks the sides are counted depending on pieces

Parameters
  • x – width of matching roundedPlate

  • y – height of matching roundedPlate

  • r – corner radius of matching roundedPlate

  • h – inner height of the wall (without edges)

  • bottom – (Default value = ‘e’) Edge type

  • top – (Default value = ‘e’) Edge type

  • left – (Default value = ‘D’) left edge(s)

  • right – (Default value = ‘d’) right edge(s)

  • pieces – (Default value = 1) number of separate pieces

  • callback – (Default value = None)

  • move – (Default value = None)

text(text, x=0, y=0, angle=0, align='', fontsize=10, color=[0.0, 0.0, 0.0])[source]

Draw text

Parameters
  • text – text to render

  • x – (Default value = 0)

  • y – (Default value = 0)

  • angle – (Default value = 0)

  • align – (Default value = “”) string with combinations of (top|middle|bottom) and (left|center|right) separated by a space

trapezoidSideWall(w, h0, h1, edges='eeee', radius=0.0, callback=None, move=None)[source]

Rectangular trapezoidal wall

Parameters
  • w – width

  • h0 – left height

  • h1 – right height

  • edges – (Default value = “eeee”) bottom, right, left

  • radius – (Default vaule = 0.0) radius of upper corners

  • callback – (Default value = None)

  • move – (Default value = None)

trapezoidWall(w, h0, h1, edges='eeee', callback=None, move=None)[source]

Rectangular trapezoidal wall

Parameters
  • w – width

  • h0 – left height

  • h1 – right height

  • edges – (Default value = “eee”) bottom, right, left

  • callback – (Default value = None)

  • move – (Default value = None)

tx_sizes = {1: 0.61, 2: 0.7, 3: 0.82, 4: 0.96, 5: 1.06, 6: 1.27, 7: 1.49, 8: 1.75, 9: 1.87, 10: 2.05, 15: 2.4, 20: 2.85, 25: 3.25, 30: 4.05, 40: 4.85, 45: 5.64, 50: 6.45, 55: 8.05, 60: 9.6, 70: 11.2, 80: 12.8, 90: 14.4, 100: 16.0}
ui_group = 'Misc'
webinterface = True
class boxes.NutHole(boxes, settings)[source]

Bases: object

Draw a hex nut

sizes = {'M1.6': (3.2, 1.3), 'M10': (16, 8.4), 'M12': (18, 10.8), 'M14': (21, 12.8), 'M16': (24, 14.8), 'M2': (4, 1.6), 'M2.5': (5, 2.0), 'M20': (30, 18.0), 'M24': (36, 21.5), 'M3': (5.5, 2.4), 'M30': (46, 25.6), 'M36': (55, 31), 'M4': (7, 3.2), 'M42': (65, 34), 'M48': (75, 38), 'M5': (8, 4.7), 'M56': (85, 45), 'M6': (10, 5.2), 'M64': (95, 51), 'M8': (13.7, 6.8)}
boxes.argparseSections(s)[source]

Parse sections parameter

Parameters

s – string to parse

boxes.dist(dx, dy)[source]

Return distance

Parameters
  • dx – delta x

  • dy – delat y

boxes.holeCol(func)[source]

Wrapper: color holes differently

Parameters

func – function to wrap

boxes.restore(func)[source]

Wrapper: Restore coordiantes after function

Parameters

func – function to wrap