import sand3d as s3d
def clamp():
root = s3d.at(upright_jaw(), x=0, y=0, z=0)
top = s3d.at(bowed_jaw(), y=27, z=15)
pin = s3d.at(pivot_pin(), x=-14, y=18, z=4)
bolt = s3d.at(screw(), x=58, y=-54, z=16)
s3d.joint(&class="tok-comment">#39;joint_clampTop_01_joint_00class="tok-string">39;, top, s3d.local(root, x=-14, y=18, z=27), kind=39;revoluteclass="tok-string">39;, axis=39;+Z39;, range=(0,47))
s3d.joint(&class="tok-comment">#39;joint_jumper_01_joint_00class="tok-string">39;, pin, s3d.local(root, x=-14, y=18, z=31), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_bolt_01_joint_00class="tok-string">39;, bolt, s3d.local(root, x=58, y=-54, z=27), kind=39;continuousclass="tok-string">39;, axis=39;+Y39;)
return s3d.assembly(&class="tok-comment">#39;clamp39;, root, top, pin, bolt)
def upright_jaw(w=168, h=54, d=11, rear_h=32, tab_t=8, hole_d=12):
plate = s3d.extrude(&class="tok-comment">#39;fork39;, s3d.rect(w/2+8, h, r=4), h=d)
plate = s3d.at(plate, x=-w/4+4, y=-14, z=h/2, rx=90)
rear = s3d.extrude(&class="tok-comment">#39;rear39;, s3d.slot(l=100, d=rear_h), h=15)
rear = s3d.at(rear, x=w/2-50, y=-14, z=h/2, rx=90)
s3d.join(plate, rear)
mouth = s3d.extrude(&class="tok-comment">#39;mouth39;, s3d.slot(l=80, d=24), h=d*3)
mouth = s3d.at(mouth, x=-87, y=-d/2, z=h/2, rx=90)
s3d.cut(plate, mouth)
strip = s3d.at(s3d.extrude(&class="tok-comment">#39;strip39;, s3d.rect(w=w/4+4, d=d+4, r=2), h=h), x=-16, y=-18)
s3d.join(plate, strip)
tab = s3d.extrude(&class="tok-comment">#39;tab39;, s3d.poly([(-34,-14),(-21,25),(-14,28),(-7,25),(7,-14)]), h=tab_t)
s3d.hole(tab, d=hole_d, on=(-14,3))
tab = s3d.at(tab, z=7)
twin = s3d.at(s3d.copy(tab), z=h-15)
s3d.join(plate, tab, twin)
s3d.material(plate, &class="tok-comment">#39;steelclass="tok-string">39;, color=39;#777b7d39;)
return s3d.group(&class="tok-comment">#39;upright_jaw39;, plate)
def bowed_jaw(w=168, d=48, h=24):
outline = s3d.poly([(-w/2,10),s3d.spline([(-w/2,10),(-49,9),(-34,2),(-25,-16),(-14,-24),(15,-24),(w/2,-24)]),(w/2,-12),s3d.spline([(w/2,-12),(21,-1),(-24,18),(-48,24),(-w/2,24)])])
jaw = s3d.extrude(&class="tok-comment">#39;bowed39;, outline, h=h)
s3d.fillet(jaw, r=3)
s3d.material(jaw, &class="tok-comment">#39;steelclass="tok-string">39;, color=39;#777b7d39;)
return s3d.group(&class="tok-comment">#39;bowed_jaw39;, jaw)
def pivot_pin(d=14, h=54):
pin = s3d.cylinder(&class="tok-comment">#39;pin39;, d=d, h=h)
s3d.chamfer(pin, d=0.6)
s3d.material(pin, &class="tok-comment">#39;steelclass="tok-string">39;, color=39;#666b7039;)
return s3d.group(&class="tok-comment">#39;pivot_pin39;, pin)
def screw(length=114, shaft_d=16, nut_d=26, nut_t=12, h=22):
shaft = s3d.at(s3d.cylinder(&class="tok-comment">#39;shaft39;, d=shaft_d, h=length), y=-length/2, z=h/2, rx=-90)
nut = s3d.at(s3d.extrude(&class="tok-comment">#39;nut39;, s3d.polygon(n=6, d=nut_d), h=nut_t), y=-37, z=h/2, rx=-90)
s3d.join(shaft, nut)
s3d.material(shaft, &class="tok-comment">#39;steelclass="tok-string">39;, color=39;#696f7239;)
return s3d.group(&class="tok-comment">#39;screw39;, shaft)