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,28 +42,36 @@ else:
|
||||||
args.hole = float(args.hole)
|
args.hole = float(args.hole)
|
||||||
assert(args.height != None)
|
assert(args.height != None)
|
||||||
|
|
||||||
args.kerf2 = args.kerf/2
|
SUITABLE = False
|
||||||
args.grid = args.hole+args.padding
|
while not SUITABLE:
|
||||||
args.radius = args.hole/2
|
args.kerf2 = args.kerf/2
|
||||||
args.corner = args.corner_length*args.thickness
|
args.grid = args.hole+args.padding
|
||||||
args.corner_s = args.corner*args.stretch
|
args.radius = args.hole/2
|
||||||
args.corner_radius = 3*args.corner_s/math.pi
|
args.corner = args.corner_length*args.thickness
|
||||||
args.plug_radius = args.corner_radius-args.thickness
|
args.corner_s = args.corner*args.stretch
|
||||||
args.corner_inset = args.corner_s*math.sqrt(3)/math.pi
|
args.corner_radius = 3*args.corner_s/math.pi
|
||||||
args.plug_inset = args.plug_radius/math.sqrt(3)
|
args.plug_radius = args.corner_radius-args.thickness
|
||||||
args.interior_edge = args.grid*args.dimension*0.5+args.outside_padding
|
args.corner_inset = args.corner_s*math.sqrt(3)/math.pi
|
||||||
args.plug_edge = args.interior_edge-args.thickness
|
args.plug_inset = args.plug_radius/math.sqrt(3)
|
||||||
args.disc_radius = 0.45*(math.sqrt(3)-1)*args.plug_edge+args.plug_inset
|
args.interior_edge = args.grid*args.dimension*0.5+args.outside_padding
|
||||||
args.exterior_edge = args.interior_edge+2.0*args.thickness
|
args.opening_edge = args.interior_edge-args.thickness
|
||||||
args.interior_leg = (args.interior_edge-args.horizontal_finger-args.kerf)/2-args.corner_inset
|
args.plug_edge = args.opening_edge-args.plug_play
|
||||||
finger_length = args.interior_edge-2.0*args.corner_inset
|
args.disc_radius = 0.45*(math.sqrt(3)-1)*args.plug_edge+args.plug_inset
|
||||||
args.n_hor_fingers = max(int(finger_length/args.horizontal_finger/2), 1)
|
args.exterior_edge = args.interior_edge+2.0*args.thickness
|
||||||
args.exterior_leg = (finger_length-(2*args.n_hor_fingers-1)*args.horizontal_finger+args.kerf)/2
|
args.interior_leg = (args.interior_edge-args.horizontal_finger-args.kerf)/2-args.corner_inset
|
||||||
args.wall_leg = (args.interior_edge-args.corner-(2*args.n_hor_fingers-1)*args.horizontal_finger+args.kerf)/2
|
finger_length = args.interior_edge-2.0*args.corner_inset
|
||||||
args.exterior_slot = (args.interior_edge-args.horizontal_finger+args.kerf)/2
|
args.n_hor_fingers = max(int(finger_length/args.horizontal_finger/2), 1)
|
||||||
args.n_ver_fingers = int((args.height+args.extra_height)/args.vertical_finger)
|
args.exterior_leg = (finger_length-(2*args.n_hor_fingers-1)*args.horizontal_finger+args.kerf)/2
|
||||||
top_slot = args.extra_height+args.thickness+0.5*args.height
|
args.wall_leg = (args.interior_edge-args.corner-(2*args.n_hor_fingers-1)*args.horizontal_finger+args.kerf)/2
|
||||||
args.slots = [top_slot, top_slot+10.0]
|
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)
|
||||||
|
top_slot = args.extra_height+args.thickness+0.5*args.height
|
||||||
|
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