Automatically adjust padding; make plug hexagonal
This commit is contained in:
parent
9fa39a7a34
commit
cbc847ea42
|
@ -21,6 +21,7 @@ parser.add_argument('--thickness', default=3.0, type=float, help='Thickness of m
|
||||||
parser.add_argument('--lid', default=0.2, type=float, help='How much extra play to give the lid')
|
parser.add_argument('--lid', default=0.2, type=float, help='How much extra play to give the lid')
|
||||||
parser.add_argument('--tooth', default=0.8, type=float, help='How much to round the edges of the teeth')
|
parser.add_argument('--tooth', default=0.8, type=float, help='How much to round the edges of the teeth')
|
||||||
parser.add_argument('--flex-granularity', default=1.8, type=float, help='How much space to give a pair of flex lines')
|
parser.add_argument('--flex-granularity', default=1.8, type=float, help='How much space to give a pair of flex lines')
|
||||||
|
parser.add_argument('--plug-play', default=0.3, type=float, help='How much smaller to make the plug than the hole')
|
||||||
parser.add_argument('--verbose', action='store_true', help='Print computed parameter values')
|
parser.add_argument('--verbose', action='store_true', help='Print computed parameter values')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
assert (args.dimension % 2) == 1
|
assert (args.dimension % 2) == 1
|
||||||
|
@ -41,6 +42,8 @@ else:
|
||||||
args.hole = float(args.hole)
|
args.hole = float(args.hole)
|
||||||
assert(args.height != None)
|
assert(args.height != None)
|
||||||
|
|
||||||
|
SUITABLE = False
|
||||||
|
while not SUITABLE:
|
||||||
args.kerf2 = args.kerf/2
|
args.kerf2 = args.kerf/2
|
||||||
args.grid = args.hole+args.padding
|
args.grid = args.hole+args.padding
|
||||||
args.radius = args.hole/2
|
args.radius = args.hole/2
|
||||||
|
@ -51,7 +54,8 @@ args.plug_radius = args.corner_radius-args.thickness
|
||||||
args.corner_inset = args.corner_s*math.sqrt(3)/math.pi
|
args.corner_inset = args.corner_s*math.sqrt(3)/math.pi
|
||||||
args.plug_inset = args.plug_radius/math.sqrt(3)
|
args.plug_inset = args.plug_radius/math.sqrt(3)
|
||||||
args.interior_edge = args.grid*args.dimension*0.5+args.outside_padding
|
args.interior_edge = args.grid*args.dimension*0.5+args.outside_padding
|
||||||
args.plug_edge = args.interior_edge-args.thickness
|
args.opening_edge = args.interior_edge-args.thickness
|
||||||
|
args.plug_edge = args.opening_edge-args.plug_play
|
||||||
args.disc_radius = 0.45*(math.sqrt(3)-1)*args.plug_edge+args.plug_inset
|
args.disc_radius = 0.45*(math.sqrt(3)-1)*args.plug_edge+args.plug_inset
|
||||||
args.exterior_edge = args.interior_edge+2.0*args.thickness
|
args.exterior_edge = args.interior_edge+2.0*args.thickness
|
||||||
args.interior_leg = (args.interior_edge-args.horizontal_finger-args.kerf)/2-args.corner_inset
|
args.interior_leg = (args.interior_edge-args.horizontal_finger-args.kerf)/2-args.corner_inset
|
||||||
|
@ -63,6 +67,11 @@ args.exterior_slot = (args.interior_edge-args.horizontal_finger+args.kerf)/2
|
||||||
args.n_ver_fingers = int((args.height+args.extra_height)/args.vertical_finger)
|
args.n_ver_fingers = int((args.height+args.extra_height)/args.vertical_finger)
|
||||||
top_slot = args.extra_height+args.thickness+0.5*args.height
|
top_slot = args.extra_height+args.thickness+0.5*args.height
|
||||||
args.slots = [top_slot, top_slot+10.0]
|
args.slots = [top_slot, top_slot+10.0]
|
||||||
|
if args.exterior_leg > 2:
|
||||||
|
SUITABLE=True
|
||||||
|
else:
|
||||||
|
args.outside_padding += .5
|
||||||
|
args.padding += .2 # Try again with more padding
|
||||||
|
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
print(args, file=sys.stderr)
|
print(args, file=sys.stderr)
|
||||||
|
@ -104,7 +113,9 @@ def draw_plane(cx, cy, layer):
|
||||||
global HOLES, SHAPES, MARKS
|
global HOLES, SHAPES, MARKS
|
||||||
if layer=='interior':
|
if layer=='interior':
|
||||||
edge = args.interior_edge
|
edge = args.interior_edge
|
||||||
elif layer=='plug' or layer=='plug_mark' or layer=='opening':
|
elif layer=='opening':
|
||||||
|
edge = args.opening_edge
|
||||||
|
elif layer=='plug' or layer=='plug_mark':
|
||||||
edge = args.plug_edge
|
edge = args.plug_edge
|
||||||
else:
|
else:
|
||||||
edge = args.exterior_edge
|
edge = args.exterior_edge
|
||||||
|
@ -131,19 +142,14 @@ def draw_plane(cx, cy, layer):
|
||||||
turtle.forward(edge-2.0*args.corner_inset)
|
turtle.forward(edge-2.0*args.corner_inset)
|
||||||
turtle.circle(-args.corner_radius, 60)
|
turtle.circle(-args.corner_radius, 60)
|
||||||
elif layer=='plug' or layer=='plug_mark':
|
elif layer=='plug' or layer=='plug_mark':
|
||||||
turtle.forward(args.plug_inset)
|
|
||||||
turtle.pendown()
|
turtle.pendown()
|
||||||
for side in range(6):
|
for side in range(3):
|
||||||
|
turtle.forward(0.5*edge)
|
||||||
turtle.right(90)
|
turtle.right(90)
|
||||||
turtle.circle(0.5*edge-args.plug_inset, 180)
|
turtle.circle(0.5*edge, 120)
|
||||||
turtle.right(90)
|
turtle.right(90)
|
||||||
turtle.circle(-args.plug_radius, 60)
|
turtle.forward(0.5*edge)
|
||||||
elif layer=='opening':
|
turtle.right(60)
|
||||||
turtle.forward(args.plug_inset)
|
|
||||||
turtle.pendown()
|
|
||||||
for side in range(6):
|
|
||||||
turtle.forward(edge-2.0*args.plug_inset)
|
|
||||||
turtle.circle(-args.plug_radius, 60)
|
|
||||||
else:
|
else:
|
||||||
turtle.pendown()
|
turtle.pendown()
|
||||||
for side in range(6):
|
for side in range(6):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user