Drawing commands

Turtle Graphics commands

These commands all move the coordinate system with them.

Boxes.edge(length, tabs=0)[source]

Simple line :param length: length in mm

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

Draw a corner

This is what does the burn corrections

Parameters:
  • degrees – angle

  • radius – (Default value = 0)

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

control point 1, control point 2, end point

Parameters:
  • x1

  • y1

  • x2

  • y2

  • x3

  • y3

Boxes.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)

Special Functions

Boxes.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) Dimensions of the slot

Latch and Grip

These should probably be Edge classes. But right now they are still functions.

Boxes.grip(length, depth)[source]

Corrugated edge useful as a gipping area

Parameters:
  • length – length

  • depth – depth of the grooves

Boxes.latch(length, positive=True, reverse=False, extra_length=0.0)[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

Boxes.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 the grip hole

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

Tab support

Tabs are small interruptions in the border of a part to keep it in place. They are enabled with the tabs parameter. All Edges automatically create about two tabs. So parts like boxes.Boxes.rectangularWall() will have 8 tabs holding them in place. Because of this developers often don’t need to be concerned about tabs. But some part may be completely drawn by low level Turtle Graphics commands. For those both boxes.Boxes.edge() and boxes.Boxes.corner() do support a tabs parameter. In addition the length of the line segments in boxes.Boxes.polyline() can be given as a tuple (length, tabs).

Draw Commands

These commands do not change the coordinate system but get the coordinates passed as parameters. All of them are either some sort of hole or text. These artifacts are placed somewhere independently of some continuous outline of the part their on.

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

Draw a round hole

Parameters:
  • x – x position

  • y – y position

  • r – radius

Boxes.rectangularHole(x, y, dx, dy, r=0, center_x=True, center_y=True)[source]

Draw a rectangular hole

Parameters:
  • x – x position

  • y – y position

  • dx – width

  • dy – height

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

  • center_x – (Default value = True) if True, x position is the center, else the start

  • center_y – (Default value = True) if True, y position is the center, else the start

Boxes.dHole(x, y, r=None, d=None, w=None, rel_w=0.75, angle=0)[source]

Draw a hole for a shaft with flat edge - D shaped hole

Parameters:
  • x – center x position

  • y – center y position

  • r – radius (overrides d)

  • d – diameter

  • w – width measured against flat side in mm

  • rel_w – width in percent

  • angle – orientation (rotation) of the flat side

Boxes.flatHole(x, y, r=None, d=None, w=None, rel_w=0.75, angle=0)[source]

Draw a hole for a shaft with two opposed flat edges - ( ) shaped hole

Parameters:
  • x – center x position

  • y – center y position

  • r – radius (overrides d)

  • d – diameter

  • w – width measured against flat side in mm

  • rel_w – width in percent

  • angle – orientation (rotation) of the flat sides

Boxes.text(text, x=0, y=0, angle=0, align='', fontsize=10, color=[0.0, 0.0, 0.0], font='Arial')[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

Boxes.NEMA(size, x=0, y=0, angle=0, screwholes=None)[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)

  • screwholes

Boxes.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)

Boxes.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

class NutHole

An instance is available as boxes.Boxes.nutHole()

An instance of

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

Hole matching a finger joint edge

is accessible as Boxes.fingerHolesAt.

Hexagonal Hole patterns

Hexagonal hole patterns are one way to have some ventilation for housings made with Boxes.py. Right now both .rectangularWall() and .roundedPlate() do supports this pattern directly by passing the parameters to the calls. For other use cases these more low level methods can be used.

For now this is the only supported pattern for ventilation slots. More may be added in the future.

There is a global Boxes.hexHolesSettings object that is used if no settings are passed. It currently is just a tuple of (r, dist, style) defaulting to (5, 3, ‘circle’) but might be replace by a Settings instance in the future.

Boxes.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

Boxes.hexHolesCircle(d, settings=None)[source]

Fill circle with holes in a hex pattern

Parameters:
  • d – diameter of the circle

  • settings – (Default value = None)

Boxes.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)

Boxes.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)