import sand3d as s3d
def ratchet():
root = s3d.at(body_01(), x=4.367, y=4.306)
return s3d.assembly(class="tok-string">"ratchet", root)
def body_01(head_w=38.68, head_h=16, shaft_d=12, shaft_l=55, grip_w=29, grip_h=24, hole_d=6, head_end=-82, neck=-33, grip_start=11, butt=101.5, drive_d=15, button_d=10):
r = head_w/2
outline = s3d.poly([(hole_d,neck),(grip_start,-50),(r,-69),(r,head_end),s3d.arc(center=(0,head_end),r=r,start=0,end=-180),(-r,-69),(-grip_start,-50),(-hole_d,neck)])
head = s3d.at(s3d.extrude(class="tok-string">"head", outline, h=head_h), z=4)
head = s3d.fillet(head, r=2)
head = s3d.hole(head, d=drive_d, depth=2, on=head.face(class="tok-string">"top").move(y=-85))
head = s3d.hole(head, d=button_d, depth=2, on=head.face(class="tok-string">"bottom").move(y=85))
shaft = s3d.at(s3d.cylinder(class="tok-string">"shaft", d=shaft_d, h=shaft_l), y=neck-5, z=grip_h/2, rx=-90)
grip = s3d.body(class="tok-string">"grip", plan=[(grip_start,grip_h),(grip_h,grip_h),(48,28),(62,grip_w),(80,head_w-shaft_d),(94,21),(butt-2,shaft_d),(butt,1)], top=[(grip_start,grip_h),(70,grip_h),(94,21),(butt-2,head_h+1),(butt,13)], bottom=[(grip_start,0),(70,0),(94,3),(butt-2,grip_h-head_h-1),(butt,grip_start)], n=2)
grip = s3d.hole(grip, d=hole_d, on=(0,92))
s3d.material(head, class="tok-string">"chrome", color=class="tok-string">"class="tok-comment">#b5b9bc")
s3d.material(shaft, class="tok-string">"chrome", color=class="tok-string">"class="tok-comment">#b5b9bc")
s3d.material(grip, class="tok-string">"rubber", color=class="tok-string">"class="tok-comment">#25282b")
class="tok-comment"># Controls are centred on the measured underside lever and drive axes.
switch = s3d.at(switch_01(), x=3.5, y=-59.5, z=2)
button = s3d.at(button_01(), y=-85, z=2)
drive = s3d.at(drive_01(), y=-85, z=19)
s3d.joint(class="tok-string">"joint_switch_01_joint_00", switch, on=s3d.local(head, x=0, y=-63, z=4), kind=class="tok-string">"revolute", axis=class="tok-string">"+Z", range=(0,75))
s3d.joint(class="tok-string">"joint_button_01_joint_00", button, on=s3d.local(head, x=0, y=-85, z=2), kind=class="tok-string">"prismatic", axis=class="tok-string">"+Z", range=(0,1.1))
s3d.joint(class="tok-string">"joint_drive_01_joint_00", drive, on=s3d.local(head, x=0, y=-85, z=25), kind=class="tok-string">"continuous", axis=class="tok-string">"+Z")
return s3d.group(class="tok-string">"body_01", head, shaft, grip, switch, button, drive)
def switch_01(w=13, d=15, h=3, plate=1.5, ridge=1.4):
class="tok-comment"># Measured teardrop plate outline, relative to its bounding-box centre.
outline = s3d.poly([(-6,-4),(-5,-7),(-1,-7),(1,-4),(6,5),(6,7),(4,8),(-5,0)], fillet=1)
lever = s3d.at(s3d.extrude(class="tok-string">"switch", outline, h=plate), z=h-plate)
rib = s3d.wire(class="tok-string">"switch_rib", path=[(-0.5,-1.5,ridge/2),(5,6,ridge/2)], d=ridge)
lever = s3d.join(lever,rib)
s3d.material(lever, class="tok-string">"chrome", color=class="tok-string">"class="tok-comment">#b5b9bc")
return s3d.group(class="tok-string">"switch_01", lever)
def button_01(d=10, h=3, bevel=0.7, wall=1):
button = s3d.cylinder(class="tok-string">"button", d=d, h=h)
button = s3d.chamfer(button, d=bevel, edges=class="tok-string">"bottom")
button = s3d.shell(button, t=wall, open=class="tok-string">"top")
s3d.material(button, class="tok-string">"chrome", color=class="tok-string">"class="tok-comment">#b5b9bc")
return s3d.group(class="tok-string">"button_01", button)
def drive_01(d=15, w=9.5, h=12, seat_h=1.5, wall=1):
seat = s3d.tube(class="tok-string">"seat", d=d, d_in=d-wall*2, h=seat_h)
post = s3d.box(class="tok-string">"post", w=w, d=w, h=h)
post = s3d.chamfer(post, d=0.6)
post = s3d.shell(post, t=wall, open=class="tok-string">"bottom")
drive = s3d.join(seat, post)
s3d.material(drive, class="tok-string">"steel", color=class="tok-string">"class="tok-comment">#92999f")
return s3d.group(class="tok-string">"drive_01", drive)