import sand3d as s3d
def ratchet():
grip = s3d.at(handle_01(), x=7, y=108.5)
body = s3d.at(body_01(), x=7, y=-33, z=2)
s3d.joint(&class="tok-comment">#39;joint_body_01_joint_00class="tok-string">39;, body, on=s3d.local(grip, x=0, y=-140.5, z=13), kind=39;continuousclass="tok-string">39;, axis=39;-Y39;)
return s3d.assembly(&class="tok-comment">#39;ratchet39;, grip, body)
def handle_01(length=107, axis_h=13, start=55, shoulder=84, waist=128, end=162, neck_d=18, swell_d=24, waist_d=16, end_d=25):
profile = [(0,0), (neck_d/2,0), (neck_d/2,75-start), (swell_d/2,81-start), (swell_d/2,87-start), (neck_d/2,94-start), (waist_d/2,waist-start), (neck_d/2,138-start), (end_d/2,148-start), (end_d/2,156-start), (22/2,length), (0,length)]
grip = s3d.revolve(&class="tok-comment">#39;grip39;, s3d.poly(profile))
grip = s3d.at(grip, y=-length/2, z=axis_h, rx=-90)
s3d.material(grip, &class="tok-comment">#39;chromeclass="tok-string">39;, color=39;#a3a5a739;, roughness=0.28)
return s3d.group(&class="tok-comment">#39;handle_0139;, grip)
def body_01(w=32, h=18, head_y=-104, shoulder_y=-87, neck_y=-66, shaft_end=120, shaft_d=15, axis_h=11, rim_d=29, rim_h=1, neck_step=-79, relief=5):
outline = s3d.poly([(-w/2,head_y), s3d.arc(center=(0,head_y), r=w/2, start=180, end=360), (w/2,shoulder_y), (shaft_d/2,neck_y), (-shaft_d/2,neck_y), (-w/2,shoulder_y)])
head = s3d.extrude(&class="tok-comment">#39;head39;, outline, h=h)
head = s3d.fillet(head, r=1, edges=&class="tok-comment">#39;all39;)
relief_tool = s3d.at(s3d.box(&class="tok-comment">#39;neck_relief39;, w=w*2, d=neck_y-neck_step+2, h=relief+1), y=(neck_step+neck_y)/2, z=-1)
head = s3d.cut(head, relief_tool)
shaft = s3d.at(s3d.cylinder(&class="tok-comment">#39;shaft39;, d=shaft_d, h=shaft_end-neck_y), y=neck_y, z=axis_h, rx=-90)
head = s3d.join(head, shaft)
face = s3d.at(s3d.extrude(&class="tok-comment">#39;face_rim39;, s3d.ellipse(w=rim_d, d=36), h=rim_h), y=head_y+3, z=h-rim_h/2)
head = s3d.join(head, face)
head = s3d.hole(head, d=8, cbore=(18,3), on=(0,-103.5))
s3d.material(head, &class="tok-comment">#39;chromeclass="tok-string">39;, color=39;#a3a5a739;, roughness=0.25)
lever = s3d.at(lever_01(), x=-3, y=-82, z=1)
gear = s3d.at(gear_01(), y=-103.5, z=16)
button = s3d.at(button_01(), y=-103.5)
s3d.joint(&class="tok-comment">#39;joint_lever_01_joint_00class="tok-string">39;, lever, on=s3d.local(head, x=0, y=-85, z=1), kind=39;revoluteclass="tok-string">39;, axis=39;+Z39;, range=(-90,0))
s3d.joint(&class="tok-comment">#39;joint_gear_01_joint_00class="tok-string">39;, gear, on=s3d.local(head, x=0, y=-103, z=27), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_button_01_joint_00class="tok-string">39;, button, on=s3d.local(head, x=0, y=-103, z=0), kind=39;prismaticclass="tok-string">39;, axis=39;+Z39;, range=(0,0.000001))
return s3d.group(&class="tok-comment">#39;body_0139;, head, lever, gear, button)
def lever_01(w=14, d=14, h=4, hub=8, tip=5, reach=8):
hub_profile = s3d.circle(d=hub)
tip_solid = s3d.at(s3d.cylinder(&class="tok-comment">#39;tip_outline39;, d=tip, h=h/2), x=-reach/2, y=reach/2)
boss = s3d.at(s3d.cone(&class="tok-comment">#39;selector_hub39;, d=hub, d2=hub-2, h=h), x=3, y=-3)
paddle = s3d.extrude(&class="tok-comment">#39;paddle39;, s3d.slot(l=reach+tip, d=tip), h=h/2)
paddle = s3d.at(paddle, x=-0.5, y=0.5, rz=-45)
plate = s3d.join(paddle, boss, tip_solid)
s3d.material(plate, &class="tok-comment">#39;chromeclass="tok-string">39;, color=39;#888b8e39;)
return s3d.group(&class="tok-comment">#39;lever_0139;, plate)
def gear_01(d=18, h=12, peg=9.5, seat_h=3):
seat = s3d.cylinder(&class="tok-comment">#39;drive_seat39;, d=d, h=seat_h)
peg_solid = s3d.at(s3d.box(&class="tok-comment">#39;square_drive39;, w=peg, d=peg, h=h-seat_h), z=seat_h-0.2)
peg_solid = s3d.chamfer(peg_solid, d=0.5)
seat = s3d.join(seat, peg_solid)
s3d.material(seat, &class="tok-comment">#39;steelclass="tok-string">39;, color=39;#868b8e39;, roughness=0.25)
return s3d.group(&class="tok-comment">#39;gear_0139;, seat)
def button_01(d=8, h=4):
button = s3d.cylinder(&class="tok-comment">#39;release39;, d=d, h=h)
s3d.material(button, &class="tok-comment">#39;steelclass="tok-string">39;, color=39;#95999c39;)
return s3d.group(&class="tok-comment">#39;button_0139;, button)