Ejemplo n.º 1
0
def interlock_groove(length, thickness, finger_play, cx=0, cy=0, rotation=0):
    mortise(length, thickness, finger_play, 0, 0, 0)
    bpy.ops.transform.translate(value=(length / 2 - finger_play / 2, 0.0, 0.0))
    bpy.ops.object.transform_apply(location=True, rotation=False, scale=False)
    bpy.context.active_object.rotation_euler.z = rotation
    bpy.ops.transform.translate(value=(cx, cy, 0.0))
    simple.active_name("_groove")
Ejemplo n.º 2
0
def finger_pair(name, dx=0, dy=0):
    simple.make_active(name)

    xpos = (dx / 2) * 1.006
    ypos = 1.006 * dy / 2

    bpy.ops.object.duplicate_move(
        OBJECT_OT_duplicate={
            "linked": False,
            "mode": 'TRANSLATION'
        },
        TRANSFORM_OT_translate={"value": (xpos, ypos, 0.0)})
    simple.active_name("_finger_pair")

    simple.make_active(name)

    bpy.ops.object.duplicate_move(
        OBJECT_OT_duplicate={
            "linked": False,
            "mode": 'TRANSLATION'
        },
        TRANSFORM_OT_translate={"value": (-xpos, -ypos, 0.0)})
    simple.active_name("_finger_pair")
    simple.join_multiple("_finger_pair")
    bpy.ops.object.select_all(action='DESELECT')
    return bpy.context.active_object
Ejemplo n.º 3
0
def make_variable_flex_pocket(height, finger_thick, pocket_width, locations):
    #   creates pockets pocket using mortise function for kerf bending
    for dist in locations:
        mortise(height - 2 * finger_thick, pocket_width, 0, dist, 0,
                math.pi / 2)
        simple.active_name("_flex_pocket")

    simple.join_multiple("_flex_pocket")
    simple.active_name("flex_pocket")
Ejemplo n.º 4
0
def twist_separator_slot(length,
                         thickness,
                         finger_play=0.00005,
                         percentage=0.5):
    simple.add_rectangle(thickness + finger_play / 2, length, center_y=False)
    simple.move(y=((length * percentage - finger_play / 2) / 2))
    simple.duplicate()
    simple.mirrory()
    simple.join_multiple('simple_rectangle')
    simple.active_name('_separator_slot')
Ejemplo n.º 5
0
def make_flex_pocket(length, height, finger_thick, finger_width, pocket_width):
    #   creates pockets pocket using mortise function for kerf bending
    dist = 3 * finger_width / 2
    while dist < length:
        mortise(height - 2 * finger_thick, pocket_width, 0, dist, 0,
                math.pi / 2)
        simple.active_name("_flex_pocket")
        dist += finger_width * 2

    simple.join_multiple("_flex_pocket")
    simple.active_name("flex_pocket")
Ejemplo n.º 6
0
def rack(mm_per_tooth=0.01,
         number_of_teeth=11,
         height=0.012,
         pressure_angle=0.3488,
         backlash=0.0,
         hole_diameter=0.003175,
         tooth_per_hole=4):
    simple.deselect()
    pi = math.pi
    mm_per_tooth *= 1000
    a = mm_per_tooth / pi  # addendum
    t = (a * math.sin(pressure_angle)
         )  # tooth side is tilted so top/bottom corners move this amount
    a /= 1000
    mm_per_tooth /= 1000
    t /= 1000

    shapely_gear = Polygon([(-mm_per_tooth * 2 / 4 * 1.001, a - height),
                            (-mm_per_tooth * 2 / 4 * 1.001 - backlash, -a),
                            (-mm_per_tooth * 1 / 4 + backlash - t, -a),
                            (-mm_per_tooth * 1 / 4 + backlash + t, a),
                            (mm_per_tooth * 1 / 4 - backlash - t, a),
                            (mm_per_tooth * 1 / 4 - backlash + t, -a),
                            (mm_per_tooth * 2 / 4 * 1.001 + backlash, -a),
                            (mm_per_tooth * 2 / 4 * 1.001, a - height)])

    utils.shapelyToCurve('_tooth', shapely_gear, 0.0)
    i = number_of_teeth
    while i > 1:
        simple.duplicate(x=mm_per_tooth)
        i -= 1
    simple.union('_tooth')
    simple.move(y=height / 2)
    if hole_diameter > 0:
        bpy.ops.curve.simple(align='WORLD',
                             location=(mm_per_tooth / 2, 0, 0),
                             rotation=(0, 0, 0),
                             Simple_Type='Circle',
                             Simple_radius=hole_diameter / 2,
                             shape='3D',
                             use_cyclic_u=True,
                             edit_mode=False)
        simple.active_name('_hole')
        distance = (number_of_teeth - 1) * mm_per_tooth
        while distance > tooth_per_hole * mm_per_tooth:
            simple.duplicate(x=tooth_per_hole * mm_per_tooth)
            distance -= tooth_per_hole * mm_per_tooth
        simple.difference('_', '_tooth')

    name = 'rack-' + str(round(mm_per_tooth * 1000, 1))
    name += '-PA-' + str(round(math.degrees(pressure_angle), 1))
    simple.active_name(name)
Ejemplo n.º 7
0
def mortise(length, thickness, finger_play, cx=0, cy=0, rotation=0):
    bpy.ops.curve.simple(align='WORLD',
                         location=(cx, cy, 0),
                         rotation=(0, 0, rotation),
                         Simple_Type='Rectangle',
                         Simple_width=length + finger_play,
                         Simple_length=thickness,
                         shape='3D',
                         outputType='POLY',
                         use_cyclic_u=True,
                         handleType='AUTO',
                         edit_mode=False)
    simple.active_name("_mortise")
Ejemplo n.º 8
0
def bar(width, thick, diameter, tolerance, amount=0, stem=1, twist=False, tneck=0.5, tthick=0.01, twist_keep=False,
        twist_line=False, twist_line_amount=2, which='MF'):

    # width = length of the bar
    # thick = thickness of the bar
    # diameter = diameter of the tool for joint creation
    # tolerance = Tolerance in the joint
    # amount = amount of fingers in the joint 0 means auto generate
    # stem = amount of radius the stem or neck of the joint will have
    # twist = twist lock addition
    # tneck = percentage the twist neck will have compared to thick
    # tthick = thicknest of the twist material
    # Which M,F, MF, MM, FF

    global DT
    if amount == 0:
        amount = round(thick / ((4 + 2 * (stem - 1)) * diameter * DT)) - 1
    bpy.ops.curve.simple(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0), Simple_Type='Rectangle',
                         Simple_width=width, Simple_length=thick, use_cyclic_u=True, edit_mode=False)
    simple.active_name('tmprect')

    fingers(diameter, tolerance, amount, stem=stem)

    if which == 'MM' or which == 'M' or which == 'MF':
        simple.rename('fingers', '_tmpfingers')
        simple.rotate(-math.pi / 2)
        simple.move(x=width / 2)
        simple.rename('tmprect', '_tmprect')
        simple.union('_tmp')
        simple.active_name("tmprect")
        twistm('tmprect', thick, diameter, tolerance, twist, tneck, tthick, -math.pi / 2,
               x=width / 2, twist_keep=twist_keep)

    twistf('receptacle', thick, diameter, tolerance, twist, tneck, tthick, twist_keep=twist_keep)
    simple.rename('receptacle', '_tmpreceptacle')
    if which == 'FF' or which == 'F' or which == 'MF':
        simple.rotate(-math.pi / 2)
        simple.move(x=-width / 2)
        simple.rename('tmprect', '_tmprect')
        simple.difference('_tmp', '_tmprect')
        simple.active_name("tmprect")
        if twist_keep:
            simple.make_active('twist_keep_f')
            simple.rotate(-math.pi / 2)
            simple.move(x=-width / 2)
           
    simple.remove_multiple("_")  # Remove temporary base and holes
    simple.remove_multiple("fingers")  # Remove temporary base and holes

    if twist_line:
        joinery.twist_line(thick, tthick, tolerance, tneck, twist_line_amount, width)
        if twist_keep:
            simple.duplicate()
        simple.active_name('tmptwist')
        simple.difference('tmp', 'tmprect')
    simple.rename('tmprect', 'Puzzle_bar')
    simple.remove_multiple("tmp")  # Remove temporary base and holes
    simple.make_active('Puzzle_bar')
Ejemplo n.º 9
0
def t(length, thick, diameter, tolerance, amount=0, stem=1, twist=False, tneck=0.5, tthick=0.01, combination='MF',
      base_gender='M', corner=False):
    if corner:
        if combination == 'MF':
            base_gender = 'M'
            combination = 'f'
        elif combination == 'F':
            base_gender = 'F'
            combination = 'f'
        elif combination == 'M':
            base_gender = 'M'
            combination = 'm'

    bar(length, thick, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck,
        tthick=tthick, which=base_gender)
    simple.active_name('tmp')
    fingers(diameter, tolerance, amount=amount, stem=stem)
    if combination == 'MF' or combination == 'M' or combination == 'm':
        simple.make_active('fingers')
        simple.move(y=thick / 2)
        simple.duplicate()
        simple.active_name('tmp')
        simple.union('tmp')

    if combination == 'M':
        simple.make_active('fingers')
        simple.mirrory()
        simple.active_name('tmp')
        simple.union('tmp')

    if combination == 'MF' or combination == 'F' or combination == 'f':
        simple.make_active('receptacle')
        simple.move(y=-thick / 2)
        simple.duplicate()
        simple.active_name('tmp')
        simple.difference('tmp', 'tmp')

    if combination == 'F':
        simple.make_active('receptacle')
        simple.mirrory()
        simple.active_name('tmp')
        simple.difference('tmp', 'tmp')

    simple.remove_multiple('receptacle')
    simple.remove_multiple('fingers')

    simple.rename('tmp', 't')
    simple.make_active('t')
Ejemplo n.º 10
0
def multiangle(radius, thick, angle, diameter, tolerance, amount=0, stem=1, twist=False,
               tneck=0.5, tthick=0.01, combination='MFF'):
    # length is the total width of the segments including 2 * radius and thick
    # radius = radius of the curve
    # thick = thickness of the bar
    # angle = angle of the female part
    # diameter = diameter of the tool for joint creation
    # tolerance = Tolerance in the joint
    # amount = amount of fingers in the joint 0 means auto generate
    # stem = amount of radius the stem or neck of the joint will have
    # twist = twist lock addition
    # tneck = percentage the twist neck will have compared to thick
    # tthick = thicknest of the twist material
    # which = which joint to generate, Male Female MaleFemale M, F, MF

    r_exterior = radius + thick / 2
    r_interior = radius - thick / 2

    height = math.sqrt(r_exterior * r_exterior - radius * radius) + r_interior / 4

    bpy.ops.curve.simple(align='WORLD', location=(0, height, 0),
                         rotation=(0, 0, 0), Simple_Type='Rectangle',
                         Simple_width=r_interior, Simple_length=r_interior / 2, use_cyclic_u=True,
                         edit_mode=False, shape='3D')
    simple.active_name('tmp_rect')

    bpy.ops.curve.simple(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0), Simple_Type='Circle', Simple_sides=4,
                         Simple_radius=r_interior, shape='3D', use_cyclic_u=True, edit_mode=False)
    simple.move(y=radius * math.tan(angle))
    simple.active_name('tmpCircle')

    arc(radius, thick, angle, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck, tthick=tthick,
        which='MF')
    simple.active_name('tmp_arc')
    if combination == 'MFF':
        simple.duplicate()
        simple.mirrorx()
    elif combination == 'MMF':
        arc(radius, thick, angle, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck,
            tthick=tthick,
            which='M')
        simple.active_name('tmp_arc')
        simple.mirrory()
        simple.rotate(math.pi / 2)
    simple.union("tmp_")
    simple.difference('tmp', 'tmp_')
    simple.active_name('multiAngle60')
Ejemplo n.º 11
0
def interlock_twist_separator(length,
                              thickness,
                              amount,
                              spacing,
                              edge_distance,
                              finger_play=0.00005,
                              percentage=0.5,
                              start='rounded',
                              end='rounded'):
    amount -= 1
    base_width = 2 * edge_distance + spacing * amount + thickness
    simple.add_rectangle(base_width, length - finger_play * 2, center_x=False)
    simple.active_name('_base')
    twist_separator_slot(length, thickness, finger_play, percentage)
    while amount > 0:
        simple.duplicate(x=spacing)
        amount -= 1
    simple.join_multiple('_separator_slot')
    simple.move(x=edge_distance + thickness / 2)
    simple.difference('_', '_base')
    simple.active_name('twist_separator')
Ejemplo n.º 12
0
def vertical_finger(length, thickness, finger_play, amount):
    #   creates _vfa and it's counterpart _vfb
    #   _vfa is starts at 0,0
    #   _wfb is _wfa offset vertically by one length
    #   takes in the
    #   length = length of the mortise
    #   thickness = thickness of the material
    #   fingerplay = tolerance in length of the finger for smooth fit
    #   amount = amount of fingers

    for i in range(amount):
        mortise(length,
                thickness,
                finger_play,
                0,
                i * 2 * length + length / 2,
                rotation=math.pi / 2)
        simple.active_name("_height_finger")

    simple.join_multiple("_height_finger")
    simple.active_name("_vfa")
    bpy.ops.object.duplicate_move(
        OBJECT_OT_duplicate={
            "linked": False,
            "mode": 'TRANSLATION'
        },
        TRANSFORM_OT_translate={"value": (0, -length, 0.0)})
    simple.active_name("_vfb")
Ejemplo n.º 13
0
def fingers(diameter, inside, amount=1, stem=1):
    # diameter = diameter of the tool for joint creation
    # inside = Tolerance in the joint receptacle
    global DT  # Bit diameter tolerance
    # stem = amount of radius the stem or neck of the joint will have
    # amount = the amount of fingers

    xtranslate = -(4 + 2 * (stem - 1)) * (amount - 1) * diameter * DT / 2
    finger(diameter, stem=stem)  # generate male finger
    simple.active_name("puzzlem")
    simple.move(x=xtranslate, y=-0.00002)

    if amount > 1:
        # duplicate translate the amount needed (faster than generating new)
        for i in range(amount - 1):
            bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked": False, "mode": 'TRANSLATION'},
                                          TRANSFORM_OT_translate={
                                              "value": ((4 + 2 * (stem - 1)) * diameter * DT, 0, 0.0)})
        simple.union('puzzle')

    simple.active_name("fingers")
    bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')

    # Receptacle is made using the silhouette offset from the fingers
    if inside > 0:
        bpy.ops.object.silhouete_offset(offset=inside, style='1')
        simple.active_name('receptacle')
        simple.move(y=-inside)
Ejemplo n.º 14
0
def twistf(name, length, diameter, tolerance, twist, tneck, tthick, twist_keep=False):
    # add twist lock to receptacle
    if twist:
        joinery.interlock_twist(length, tthick, tolerance, cx=0, cy=0, rotation=0, percentage=tneck)
        simple.rotate(math.pi / 2)
        simple.move(y=-tthick / 2 + 2 * diameter + 2 * tolerance)
        simple.active_name('xtemptwist')
        if twist_keep:
            simple.duplicate()
            simple.active_name('twist_keep_f')
        simple.make_active(name)
        simple.active_name('xtemp')
        simple.union('xtemp')
        simple.active_name(name)
Ejemplo n.º 15
0
def interlock_twist(length,
                    thickness,
                    finger_play,
                    cx=0,
                    cy=0,
                    rotation=0,
                    percentage=0.5):
    mortise(length, thickness, finger_play, 0, 0, 0)
    simple.active_name("_tmp")
    mortise(length * percentage, thickness, finger_play, 0, 0, math.pi / 2)
    simple.active_name("_tmp")
    h = math.hypot(thickness, length * percentage)
    oangle = math.degrees(math.asin(length * percentage / h))
    bpy.ops.curve.simple(align='WORLD',
                         location=(0, 0, 0),
                         rotation=(0, 0, 0),
                         Simple_Type='Sector',
                         Simple_startangle=90 + oangle,
                         Simple_endangle=180 - oangle,
                         Simple_radius=h / 2,
                         use_cyclic_u=True,
                         edit_mode=False)
    simple.active_name("_tmp")

    bpy.ops.curve.simple(align='WORLD',
                         location=(0, 0, 0),
                         rotation=(0, 0, 0),
                         Simple_Type='Sector',
                         Simple_startangle=270 + oangle,
                         Simple_endangle=360 - oangle,
                         Simple_radius=h / 2,
                         use_cyclic_u=True,
                         edit_mode=False)
    simple.active_name("_tmp")

    simple.union('_tmp')
    simple.rotate(rotation)
    simple.move(x=cx, y=cy)
    simple.active_name("_groove")
    simple.remove_doubles()
Ejemplo n.º 16
0
def create_flex_side(length, height, finger_thick, top_bottom=False):
    #   assumes the base fingers were created and exist
    #   crates a flex side for mortise on curve
    #   length = length of curve
    #   height = height of side
    #   finger_length = lenght of finger or mortise
    #   finger_thick = finger thickness or thickness of material
    #   finger_tol = Play for finger 0 is very tight
    #   top_bottom = fingers on top and bottom if true, just on bottom if false
    #   flex_pocket = width of pocket on the flex side.  This is for kerf bending.
    if top_bottom:
        fingers = finger_pair("base", 0, height - finger_thick)
    else:
        simple.make_active("base")
        fingers = bpy.context.active_object
        bpy.ops.transform.translate(value=(0.0, height / 2 - finger_thick / 2 +
                                           0.0003, 0.0))

    bpy.ops.curve.simple(align='WORLD',
                         location=(length / 2 + 0.00025, 0, 0),
                         rotation=(0, 0, 0),
                         Simple_Type='Rectangle',
                         Simple_width=length,
                         Simple_length=height,
                         shape='3D',
                         outputType='POLY',
                         use_cyclic_u=True,
                         handleType='AUTO',
                         edit_mode=False)
    simple.active_name("_side")

    simple.make_active('_side')
    fingers.select_set(True)
    bpy.ops.object.curve_boolean(boolean_type='DIFFERENCE')

    simple.active_name("side")
    simple.remove_multiple('_')
    simple.remove_multiple('base')
Ejemplo n.º 17
0
def twist_line(length,
               thickness,
               finger_play,
               percentage,
               amount,
               distance,
               center=True):
    # Makes an amount of twist for the distance and  centers it
    spacing = distance / amount
    while amount > 0:
        position = spacing * amount
        interlock_twist(length,
                        thickness,
                        finger_play,
                        percentage=percentage,
                        cx=position)
        print('twistline', amount, distance, position)
        amount -= 1

    simple.join_multiple('_groove')
    simple.active_name('twist_line')
    if center:
        simple.move(x=(-distance - spacing) / 2)
Ejemplo n.º 18
0
def fixed_finger(loop,
                 loop_length,
                 finger_size,
                 finger_thick,
                 finger_tolerance,
                 base=False):
    #   distributes mortises of a fixed distance
    #   dynamically changes the finger tolerance with the angle differences
    #   loop = takes in a shapely shape
    #   finger_size = size of the mortise
    #   finger_thick = thickness of the material
    #   finger_tolerance = minimum finger tolerance

    coords = list(loop.coords)
    old_mortise_angle = 0
    distance = finger_size / 2
    j = 0
    print("joinery loop length", round(loop_length * 1000), "mm")
    for i, p in enumerate(coords):
        if i == 0:
            p_start = p

        if p != p_start:
            not_start = True
        else:
            not_start = False
        pd = loop.project(Point(p))

        if not_start:
            while distance <= pd:
                mortise_angle = angle(oldp, p)
                mortise_angle_difference = abs(mortise_angle -
                                               old_mortise_angle)
                mad = (1 + 6 * min(mortise_angle_difference, math.pi / 4) /
                       (math.pi / 4))  # factor for tolerance for the finger

                if base:
                    mortise(finger_size, finger_thick, finger_tolerance * mad,
                            distance, 0, 0)
                    simple.active_name("_base")
                else:
                    mortise_point = loop.interpolate(distance)
                    mortise(finger_size, finger_thick, finger_tolerance * mad,
                            mortise_point.x, mortise_point.y, mortise_angle)

                j += 1
                distance = j * 2 * finger_size + finger_size / 2
                old_mortise_angle = mortise_angle
        oldp = p
    if base:
        simple.join_multiple("_base")
        simple.active_name("base")
        simple.move(x=finger_size)
    else:
        simple.join_multiple("_mort")
        simple.active_name("mortise")
Ejemplo n.º 19
0
def twistm(name, length, diameter, tolerance, twist, tneck, tthick, angle, twist_keep=False, x=0, y=0):
    # add twist lock to male connector
    global DT
    if twist:
        joinery.interlock_twist(length, tthick, tolerance, cx=0, cy=0, rotation=0, percentage=tneck)
        simple.rotate(math.pi / 2)
        simple.move(y=-tthick / 2 + 2 * diameter * DT)
        simple.rotate(angle)
        simple.move(x=x, y=y)
        simple.active_name('_twist')
        if twist_keep:
            simple.duplicate()
            simple.active_name('twist_keep_m')
        simple.make_active(name)
        simple.active_name('_tmp')
        simple.difference('_', '_tmp')
        simple.active_name(name)
Ejemplo n.º 20
0
def create_base_plate(height, width, depth):
    #   creates blank plates for
    #   _back using width and height
    #   _side using height and depth
    #   _bottom using width and depth

    bpy.ops.curve.simple(align='WORLD',
                         location=(0, height / 2, 0),
                         rotation=(0, 0, 0),
                         Simple_Type='Rectangle',
                         Simple_width=width,
                         Simple_length=height,
                         shape='3D',
                         outputType='POLY',
                         use_cyclic_u=True,
                         handleType='AUTO',
                         edit_mode=False)
    simple.active_name("_back")
    bpy.ops.curve.simple(align='WORLD',
                         location=(0, height / 2, 0),
                         rotation=(0, 0, 0),
                         Simple_Type='Rectangle',
                         Simple_width=depth,
                         Simple_length=height,
                         shape='3D',
                         outputType='POLY',
                         use_cyclic_u=True,
                         handleType='AUTO',
                         edit_mode=False)
    simple.active_name("_side")
    bpy.ops.curve.simple(align='WORLD',
                         location=(0, 0, 0),
                         rotation=(0, 0, 0),
                         Simple_Type='Rectangle',
                         Simple_width=width,
                         Simple_length=depth,
                         shape='3D',
                         outputType='POLY',
                         use_cyclic_u=True,
                         handleType='AUTO',
                         edit_mode=False)
    simple.active_name("_bottom")
Ejemplo n.º 21
0
def open_curve(line, thick, diameter, tolerance, amount=0, stem=1, twist=False, t_neck=0.5, t_thick=0.01,
               twist_amount=1, which='MF', twist_keep=False):
    # puts puzzle connectors at the end of an open curve
    # optionally puts twist lock connectors at the puzzle connection
    # optionally puts twist lock connectors along the open curve
    # line = shapely linestring
    # thick = thickness of the bar
    # diameter = diameter of the tool for joint creation
    # tolerance = Tolerance in the joint
    # amount = amount of fingers in the joint 0 means auto generate
    # stem = amount of radius the stem or neck of the joint will have
    # twist = twist lock addition
    # twist_amount = twist amount distributed on the curve not counting the joint twist locks
    # tneck = percentage the twist neck will have compared to thick
    # tthick = thicknest of the twist material
    # Which M,F, MF, MM, FF

    coords = list(line.coords)

    start_angle = joinery.angle(coords[0], coords[1]) + math.pi/2
    end_angle = joinery.angle(coords[-1], coords[-2]) + math.pi/2
    p_start = coords[0]
    p_end = coords[-1]

    print('start angle', start_angle)
    print('end angle', end_angle)

    bpy.ops.curve.simple(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0), Simple_Type='Rectangle',
                         Simple_width=thick*2, Simple_length=thick * 2, use_cyclic_u=True, edit_mode=False, shape='3D')
    simple.active_name('tmprect')
    simple.move(y=thick)
    simple.duplicate()
    simple.rotate(start_angle)
    simple.move(x=p_start[0], y=p_start[1])
    simple.make_active('tmprect')
    simple.rotate(end_angle)
    simple.move(x=p_end[0], y=p_end[1])
    simple.union('tmprect')
    dilated = line.buffer(thick/2)  # expand shapely object to thickness
    utils.shapelyToCurve('tmp_curve', dilated, 0.0)
    simple.difference('tmp', 'tmp_curve')   # truncate curve at both ends with the rectangles

    fingers(diameter, tolerance, amount, stem=stem)
    simple.make_active('fingers')
    simple.rotate(end_angle)
    simple.move(x=p_end[0], y=p_end[1])
    simple.active_name('tmp_fingers')
    simple.union('tmp_')
    simple.active_name('tmp_curve')
    twistm('tmp_curve', thick, diameter, tolerance, twist, t_neck, t_thick, end_angle, x=p_end[0], y=p_end[1],
           twist_keep=twist_keep)

    twistf('receptacle', thick, diameter, tolerance, twist, t_neck, t_thick, twist_keep=twist_keep)
    simple.rename('receptacle', 'tmp')
    simple.rotate(start_angle+math.pi)
    simple.move(x=p_start[0], y=p_start[1])
    simple.difference('tmp', 'tmp_curve')
    if twist_keep:
        simple.make_active('twist_keep_f')
        simple.rotate(start_angle + math.pi)
        simple.move(x=p_start[0], y=p_start[1])

    if twist_amount > 0 and twist:
        twist_start = line.length / (twist_amount+1)
        joinery.distributed_interlock(line, line.length, thick, t_thick, tolerance, twist_amount,
                                      tangent=math.pi/2, fixed_angle=0, start=twist_start, end=twist_start,
                                      closed=False, type='TWIST', twist_percentage=t_neck)
        if twist_keep:
            simple.duplicate()
            simple.active_name('twist_keep')
            simple.join_multiple('twist_keep')
            simple.make_active('interlock')

        simple.active_name('tmp_twist')
        simple.difference('tmp', 'tmp_curve')
        simple.active_name('puzzle_curve')
Ejemplo n.º 22
0
def mitre(length, thick, angle, angleb, diameter, tolerance, amount=0, stem=1, twist=False,
          tneck=0.5, tthick=0.01, which='MF'):
    # length is the total width of the segments including 2 * radius and thick
    # radius = radius of the curve
    # thick = thickness of the bar
    # angle = angle of the female part
    # angleb = angle of the male part
    # diameter = diameter of the tool for joint creation
    # tolerance = Tolerance in the joint
    # amount = amount of fingers in the joint 0 means auto generate
    # stem = amount of radius the stem or neck of the joint will have
    # twist = twist lock addition
    # tneck = percentage the twist neck will have compared to thick
    # tthick = thicknest of the twist material
    # which = which joint to generate, Male Female MaleFemale M, F, MF

    # generate base rectangle
    bpy.ops.curve.simple(align='WORLD', location=(0, -thick / 2, 0), rotation=(0, 0, 0), Simple_Type='Rectangle',
                         Simple_width=length * 1.005 + 4 * thick, Simple_length=thick, use_cyclic_u=True,
                         edit_mode=False,
                         shape='3D')
    simple.active_name("tmprect")

    # generate cutout shapes
    bpy.ops.curve.simple(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0), Simple_Type='Rectangle',
                         Simple_width=4 * thick, Simple_length=6 * thick, use_cyclic_u=True, edit_mode=False,
                         shape='3D')
    simple.move(x=2 * thick)
    simple.rotate(angle)
    simple.move(x=length / 2)
    simple.active_name('tmpmitreright')

    bpy.ops.curve.simple(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0), Simple_Type='Rectangle',
                         Simple_width=4 * thick, Simple_length=6 * thick, use_cyclic_u=True, edit_mode=False,
                         shape='3D')
    simple.move(x=2 * thick)
    simple.rotate(angleb)
    simple.move(x=length / 2)
    simple.mirrorx()
    simple.active_name('tmpmitreleft')
    simple.difference('tmp', 'tmprect')
    simple.make_active('tmprect')

    fingers(diameter, tolerance, amount, stem=stem)

    #  Generate male section and join to the base
    if which == 'M' or which == 'MF':
        simple.make_active('fingers')
        simple.duplicate()
        simple.active_name('tmpfingers')
        simple.rotate(angle - math.pi / 2)
        h = thick / math.cos(angle)
        h /= 2
        simple.move(x=length / 2 + h * math.sin(angle), y=-thick / 2)
        if which == 'M':
            simple.rename('fingers', 'tmpfingers')
            simple.rotate(angleb - math.pi / 2)
            h = thick / math.cos(angleb)
            h /= 2
            simple.move(x=length / 2 + h * math.sin(angleb), y=-thick / 2)
            simple.mirrorx()

        simple.union('tmp')
        simple.active_name('tmprect')

    # Generate female section and join to base
    if which == 'MF' or which == 'F':
        simple.make_active('receptacle')
        simple.mirrory()
        simple.duplicate()
        simple.active_name('tmpreceptacle')
        simple.rotate(angleb - math.pi / 2)
        h = thick / math.cos(angleb)
        h /= 2
        simple.move(x=length / 2 + h * math.sin(angleb), y=-thick / 2)
        simple.mirrorx()
        if which == 'F':
            simple.rename('receptacle', 'tmpreceptacle2')
            simple.rotate(angle - math.pi / 2)
            h = thick / math.cos(angle)
            h /= 2
            simple.move(x=length / 2 + h * math.sin(angle), y=-thick / 2)
        simple.difference('tmp', 'tmprect')

    simple.remove_multiple('receptacle')
    simple.remove_multiple('fingers')
    simple.rename('tmprect', 'mitre')
Ejemplo n.º 23
0
def curved_t(length, thick, radius, diameter, tolerance, amount=0, stem=1, twist=False, tneck=0.5, tthick=0.01,
             combination='MF', base_gender='M'):
    bar(length, thick, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck,
        tthick=tthick, which=combination)
    simple.active_name('tmpbar')

    bpy.ops.curve.simple(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0), Simple_Type='Rectangle',
                         Simple_width=3 * radius, Simple_length=thick, use_cyclic_u=True, edit_mode=False)
    simple.active_name("tmp_rect")

    if base_gender == 'MF':
        arc(radius, thick, math.pi / 2, diameter, tolerance,
            amount=amount, stem=stem, twist=twist, tneck=tneck, tthick=tthick, which='M')
        simple.move(-radius)
        simple.active_name('tmp_arc')
        arc(radius, thick, math.pi / 2, diameter, tolerance,
            amount=amount, stem=stem, twist=twist, tneck=tneck, tthick=tthick, which='F')
        simple.move(radius)
        simple.mirrory()
        simple.active_name('tmp_arc')
        simple.union('tmp_arc')
        simple.duplicate()
        simple.mirrorx()
        simple.union('tmp_arc')
        simple.difference('tmp_', 'tmp_arc')
    else:
        arc(radius, thick, math.pi / 2, diameter, tolerance,
            amount=amount, stem=stem, twist=twist, tneck=tneck, tthick=tthick, which=base_gender)
        simple.active_name('tmp_arc')
        simple.difference('tmp_', 'tmp_arc')
        if base_gender == 'M':
            simple.move(-radius)
        else:
            simple.move(radius)
        simple.duplicate()
        simple.mirrorx()

    simple.union('tmp')
    simple.active_name('curved_t')
Ejemplo n.º 24
0
def horizontal_finger(length, thickness, finger_play, amount, center=True):
    #   creates _wfa counterpart _wfb
    #   _wfa is centered at 0,0
    #   _wfb is _wfa offset by one length
    #   takes in the
    #   length = length of the mortise
    #   thickness = thickness of the material
    #   fingerplay = tolerance in length of the finger for smooth fit
    if center:
        for i in range(amount):
            if i == 0:
                mortise(length, thickness, finger_play, 0, thickness / 2)
                simple.active_name("_width_finger")
            else:
                mortise(length, thickness, finger_play, i * 2 * length,
                        thickness / 2)
                simple.active_name("_width_finger")
                mortise(length, thickness, finger_play, -i * 2 * length,
                        thickness / 2)
                simple.active_name("_width_finger")
    else:
        for i in range(amount):
            mortise(length, thickness, finger_play,
                    length / 2 + 2 * i * length, 0)
            simple.active_name("_width_finger")

    simple.join_multiple("_width_finger")

    simple.active_name("_wfa")
    bpy.ops.object.duplicate_move(
        OBJECT_OT_duplicate={
            "linked": False,
            "mode": 'TRANSLATION'
        },
        TRANSFORM_OT_translate={"value": (length, 0.0, 0.0)})
    simple.active_name("_wfb")
Ejemplo n.º 25
0
def arcbar(length, radius, thick, angle, diameter, tolerance, amount=0, stem=1, twist=False,
           tneck=0.5, tthick=0.01, twist_keep=False, which='MF', twist_line=False, twist_line_amount=2):
    # length is the total width of the segments including 2 * radius and thick
    # radius = radius of the curve
    # thick = thickness of the bar
    # angle = angle of the female part
    # diameter = diameter of the tool for joint creation
    # tolerance = Tolerance in the joint
    # amount = amount of fingers in the joint 0 means auto generate
    # stem = amount of radius the stem or neck of the joint will have
    # twist = twist lock addition
    # tneck = percentage the twist neck will have compared to thick
    # tthick = thicknest of the twist material
    # which = which joint to generate, Male Female MaleFemale M, F, MF
    if which == 'M':
        which = 'MM'
    elif which == 'F':
        which = 'FF'
    length -= (radius * 2 + thick)  # adjust length to include 2x radius + thick

    # generate base rectangle
    #  Generate male section and join to the base
    if which == 'MM' or which == 'MF':
        bar(length, thick, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck, tthick=tthick,
            which='M', twist_keep=twist_keep, twist_line=twist_line, twist_line_amount=twist_line_amount)
        simple.active_name('tmprect')

    if which == 'FF' or which == 'FM':
        bar(length, thick, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck, tthick=tthick,
            which='F', twist_keep=twist_keep, twist_line=twist_line, twist_line_amount=twist_line_amount)
        simple.rotate(math.pi)
        simple.active_name('tmprect')

    # Generate female section and join to base
    if which == 'FF' or which == 'MF':
        arc(radius, thick, angle, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck,
            tthick=tthick, which='F')
        simple.move(x=-length / 2 * 0.998)
        simple.active_name('tmp_receptacle')
        simple.union('tmp')
        simple.active_name('arcBar')
        simple.remove_multiple('tmp')

    if which == 'MM':
        arc(radius, thick, angle, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck,
            tthick=tthick, which='M')
        bpy.ops.transform.mirror(orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)),
                                 orient_matrix_type='GLOBAL', constraint_axis=(True, False, False))
        simple.move(x=-length / 2 * 0.998)
        simple.active_name('tmp_receptacle')
        simple.union('tmp')
        simple.active_name('arcBar')
        simple.remove_multiple('tmp')

    simple.make_active('arcBar')
Ejemplo n.º 26
0
def arc(radius, thick, angle, diameter, tolerance, amount=0, stem=1, twist=False, tneck=0.5, tthick=0.01,
        twist_keep=False, which='MF'):
    # radius = radius of the curve
    # thick = thickness of the bar
    # angle = angle of the arc
    # diameter = diameter of the tool for joint creation
    # tolerance = Tolerance in the joint
    # amount = amount of fingers in the joint 0 means auto generate
    # stem = amount of radius the stem or neck of the joint will have
    # twist = twist lock addition
    # tneck = percentage the twist neck will have compared to thick
    # tthick = thicknest of the twist material
    # which = which joint to generate, Male Female MaleFemale M, F, MF

    global DT  # diameter tolerance for diameter of finger creation

    if angle == 0:  # angle cannot be 0
        angle = 0.01

    negative = False
    if angle < 0:  # if angle < 0 then negative is true
        angle = -angle
        negative = True

    if amount == 0:
        amount = round(thick / ((4 + 2 * (stem - 1)) * diameter * DT)) - 1

    fingers(diameter, tolerance, amount, stem=stem)
    twistf('receptacle', thick, diameter, tolerance, twist, tneck, tthick, twist_keep=twist_keep)

    # generate arc
    bpy.ops.curve.simple(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0), Simple_Type='Segment',
                         Simple_a=radius - thick / 2,
                         Simple_b=radius + thick / 2, Simple_startangle=-0.0001, Simple_endangle=math.degrees(angle),
                         Simple_radius=radius, use_cyclic_u=False, edit_mode=False)
    bpy.context.active_object.name = "tmparc"

    simple.rename('fingers', '_tmpfingers')

    simple.rotate(math.pi)
    simple.move(x=radius)
    bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')

    simple.rename('tmparc', '_tmparc')
    if which == 'MF' or which == 'M':
        simple.union('_tmp')
        simple.active_name("base")
        twistm('base', thick, diameter, tolerance, twist, tneck, tthick, math.pi, x=radius)
        simple.rename('base', '_tmparc')

    simple.rename('receptacle', '_tmpreceptacle')
    simple.mirrory()
    simple.move(x=radius)
    bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
    simple.rotate(angle)
    simple.make_active('_tmparc')

    if which == 'MF' or which == 'F':
        simple.difference('_tmp', '_tmparc')
    bpy.context.active_object.name = "PUZZLE_arc"
    bpy.ops.object.curve_remove_doubles()
    simple.remove_multiple("_")  # Remove temporary base and holes
    simple.make_active('PUZZLE_arc')
    if which == 'M':
        simple.rotate(-angle)
        simple.mirrory()
        bpy.ops.object.transform_apply(location=True, rotation=True, scale=False)
        simple.rotate(-math.pi / 2)
        simple.move(y=radius)
        simple.rename('PUZZLE_arc', 'PUZZLE_arc_male')
    elif which == 'F':
        simple.mirrorx()
        simple.move(x=radius)
        simple.rotate(math.pi / 2)
        simple.rename('PUZZLE_arc', 'PUZZLE_arc_receptacle')
    else:
        simple.move(x=-radius)
    # bpy.ops.object.transform_apply(location=True, rotation=False, scale=False, properties=False)
    #
    if negative:  # mirror if angle is negative
        simple.mirrory()
Ejemplo n.º 27
0
def tile(diameter, tolerance, tile_x_amount, tile_y_amount, stem=1):
    global DT
    diameter = diameter * DT
    # diameter * DT * (2 + stem - 1)
    (4 + 2 * (stem - 1)) * diameter
    width = (tile_x_amount) * (4 + 2 * (stem - 1)) * diameter + diameter
    height = (tile_y_amount) * (4 + 2 * (stem - 1)) * diameter + diameter

    print('size:', width, height)
    fingers(diameter, tolerance, amount=tile_x_amount+2, stem=stem)
    simple.add_rectangle(width, height)
    simple.active_name('_base')

    simple.make_active('fingers')
    simple.active_name('_fingers')
    simple.intersect('_')
    simple.remove_multiple('_fingers')
    simple.rename('intersection', '_fingers')
    simple.move(y=height/2)
    simple.union('_')
    simple.active_name('_base')
    simple.remove_doubles()
    simple.rename('receptacle', '_receptacle')
    simple.move(y=-height/2)
    simple.difference('_', '_base')
    simple.active_name('base')
    fingers(diameter, tolerance, amount=tile_y_amount, stem=stem)
    simple.rename('base', '_base')
    simple.remove_doubles()
    simple.rename('fingers', '_fingers')
    simple.rotate(math.pi/2)
    simple.move(x=-width/2)
    simple.union('_')
    simple.active_name('_base')
    simple.rename('receptacle', '_receptacle')
    simple.rotate(math.pi/2)
    simple.move(x=width/2)
    simple.difference('_', '_base')
    simple.active_name('tile_ ' + str(tile_x_amount) + '_' + str(tile_y_amount))
Ejemplo n.º 28
0
def arcbararc(length, radius, thick, angle, angleb, diameter, tolerance, amount=0, stem=1, twist=False,
              tneck=0.5, tthick=0.01, which='MF', twist_keep=False, twist_line=False, twist_line_amount=2):
    # length is the total width of the segments including 2 * radius and thick
    # radius = radius of the curve
    # thick = thickness of the bar
    # angle = angle of the female part
    # angleb = angle of the male part
    # diameter = diameter of the tool for joint creation
    # tolerance = Tolerance in the joint
    # amount = amount of fingers in the joint 0 means auto generate
    # stem = amount of radius the stem or neck of the joint will have
    # twist = twist lock addition
    # tneck = percentage the twist neck will have compared to thick
    # tthick = thicknest of the twist material
    # which = which joint to generate, Male Female MaleFemale M, F, MF

    length -= (radius * 2 + thick)  # adjust length to include 2x radius + thick

    # generate base rectangle
    bpy.ops.curve.simple(align='WORLD', location=(0, 0, 0), rotation=(0, 0, 0), Simple_Type='Rectangle',
                         Simple_width=length * 1.005, Simple_length=thick, use_cyclic_u=True, edit_mode=False)
    simple.active_name("tmprect")

    #  Generate male section and join to the base
    if which == 'M' or which == 'MF':
        arc(radius, thick, angleb, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck,
            tthick=tthick, which='M')
        simple.move(x=length / 2)
        simple.active_name('tmp_male')
        simple.select_multiple('tmp')
        bpy.ops.object.curve_boolean(boolean_type='UNION')
        simple.active_name('male')
        simple.remove_multiple('tmp')
        simple.rename('male', 'tmprect')

    # Generate female section and join to base
    if which == 'F' or which == 'MF':
        arc(radius, thick, angle, diameter, tolerance, amount=amount, stem=stem, twist=twist, tneck=tneck,
            tthick=tthick, which='F')
        simple.move(x=-length / 2)
        simple.active_name('tmp_receptacle')
        simple.union('tmp')
        simple.active_name('tmprect')

    if twist_line:
        joinery.twist_line(thick, tthick, tolerance, tneck, twist_line_amount, length)
        if twist_keep:
            simple.duplicate()
        simple.active_name('tmptwist')
        simple.difference('tmp', 'tmprect')

    simple.active_name('arcBarArc')
    simple.make_active('arcBarArc')
Ejemplo n.º 29
0
def distributed_interlock(loop,
                          loop_length,
                          finger_depth,
                          finger_thick,
                          finger_tolerance,
                          finger_amount,
                          tangent=0,
                          fixed_angle=0,
                          start=0.01,
                          end=0.01,
                          closed=True,
                          type='GROOVE',
                          twist_percentage=0.5):
    #   distributes interlocking joints of a fixed amount
    #   dynamically changes the finger tolerance with the angle differences
    #   loop = takes in a shapely shape
    #   finger_size = size of the mortise
    #   finger_thick = thickness of the material
    #   finger_tolerance = minimum finger tolerance
    #   twist_percentage = portion of twist finger which is the stem
    coords = list(loop.coords)
    print(closed)
    if not closed:
        spacing = (loop_length - start - end) / (finger_amount - 1)
        distance = start
        end_distance = loop_length - end
    else:
        spacing = loop_length / finger_amount
        distance = 0
        end_distance = loop_length

    j = 0
    print("joinery loop length", round(loop_length * 1000), "mm")
    print("distance between joints", round(spacing * 1000), "mm")

    for i, p in enumerate(coords):
        if i == 0:
            p_start = p

        if p != p_start:
            not_start = True
        else:
            not_start = False
        pd = loop.project(Point(p))

        if not_start:
            while distance <= pd and end_distance >= distance:
                if fixed_angle == 0:
                    groove_angle = angle(oldp, p) + math.pi / 2 + tangent
                else:
                    groove_angle = fixed_angle

                groove_point = loop.interpolate(distance)

                print(j, "groove_angle", round(180 * groove_angle / math.pi),
                      "distance", round(distance * 1000), "mm")
                single_interlock(finger_depth,
                                 finger_thick,
                                 finger_tolerance,
                                 groove_point.x,
                                 groove_point.y,
                                 groove_angle,
                                 type,
                                 twist_percentage=twist_percentage)

                j += 1
                distance = j * spacing + start
        oldp = p

    simple.join_multiple("_groove")
    simple.active_name("interlock")
Ejemplo n.º 30
0
def variable_finger(loop,
                    loop_length,
                    min_finger,
                    finger_size,
                    finger_thick,
                    finger_tolerance,
                    adaptive,
                    base=False,
                    double_adaptive=False):
    #   distributes mortises of a fixed distance
    #   dynamically changes the finger tolerance with the angle differences
    #   loop = takes in a shapely shape
    #   finger_size = size of the mortise
    #   finger_thick = thickness of the material
    #   finger_tolerance = minimum finger tolerance
    #   adaptive = angle threshold to reduce finger size

    coords = list(loop.coords)
    old_mortise_angle = 0
    distance = min_finger / 2
    finger_sz = min_finger
    oldfinger_sz = min_finger
    hpos = []  # hpos is the horizontal positions of the middle of the mortise
    # slope_array(loop)
    print("joinery loop length", round(loop_length * 1000), "mm")
    for i, p in enumerate(coords):
        if i == 0:
            p_start = p

        if p != p_start:
            not_start = True
        else:
            not_start = False
        pd = loop.project(Point(p))

        if not_start:
            while distance <= pd:
                mortise_angle = angle(oldp, p)
                mortise_angle_difference = abs(mortise_angle -
                                               old_mortise_angle)
                mad = (1 + 6 * min(mortise_angle_difference, math.pi / 4) /
                       (math.pi / 4))  # factor for tolerance for the finger
                distance += mad * finger_tolerance  # move finger by the factor mad greater with larger angle difference
                mortise_point = loop.interpolate(distance)
                if mad > 2 and double_adaptive:
                    hpos.append(distance)  # saves the mortise center

                hpos.append(distance + finger_sz)  # saves the mortise center
                if base:
                    mortise(finger_sz, finger_thick, finger_tolerance * mad,
                            distance + finger_sz, 0, 0)
                    simple.active_name("_base")
                else:
                    mortise(finger_sz, finger_thick, finger_tolerance * mad,
                            mortise_point.x, mortise_point.y, mortise_angle)
                    if i == 1:
                        #  put a mesh cylinder at the first coordinates to indicate start
                        simple.remove_multiple("start_here")
                        bpy.ops.mesh.primitive_cylinder_add(
                            radius=finger_thick / 2,
                            depth=0.025,
                            enter_editmode=False,
                            align='WORLD',
                            location=(mortise_point.x, mortise_point.y, 0),
                            scale=(1, 1, 1))
                        simple.active_name("start_here_mortise")

                old_distance = distance
                old_mortise_point = mortise_point
                finger_sz = finger_size
                next_angle_difference = math.pi

                #   adaptive finger length start
                while finger_sz > min_finger and next_angle_difference > adaptive:
                    finger_sz *= 0.95  # reduce the size of finger by a percentage... the closer to 1.0, the slower
                    distance = old_distance + 3 * oldfinger_sz / 2 + finger_sz / 2
                    mortise_point = loop.interpolate(
                        distance)  # get the next mortise point
                    next_mortise_angle = angle(
                        (old_mortise_point.x, old_mortise_point.y),
                        (mortise_point.x,
                         mortise_point.y))  # calculate next angle
                    next_angle_difference = abs(next_mortise_angle -
                                                mortise_angle)

                oldfinger_sz = finger_sz
                old_mortise_angle = mortise_angle
        oldp = p
    if base:
        simple.join_multiple("_base")
        simple.active_name("base")
    else:
        print("placeholder")
        simple.join_multiple("_mort")
        simple.active_name("variable_mortise")
    return hpos