import sand3d as s3d
def mechanical_clamp():
frame = s3d.at(clamp_frame(), x=6, y=39, z=79)
return s3d.assembly(&class="tok-comment">#39;mechanical_clamp39;, frame)
def clamp_frame(post_w=46, post_d=40, post_h=171, cap_d=64, cap_h=33, bar_d=32, bar_l=126, cheek_t=18, cheek_span=81, post_y=-30, bottom=79, shoulder=28, cap_z=174, plate_y=-39, front=-64, slope_start=-29, heel=36, back=47, plate_h=113, knee=44, screw_y=-87, support_z=95, support_d=41, support_h=32):
post = s3d.at(s3d.box(&class="tok-comment">#39;upright39;, w=post_w, d=post_d, h=post_h), y=post_y, z=shoulder)
cap = s3d.hole(s3d.cylinder(&class="tok-comment">#39;cap39;, d=cap_d, h=cap_h), d=cheek_t)
bolts = s3d.at(s3d.extrude(&class="tok-comment">#39;cap_bolt39;, s3d.polygon(n=6, d=10), h=6), on=s3d.ring(n=3, r=cap_d/2-8))
cap_group = s3d.group(&class="tok-comment">#39;cap_groupclass="tok-string">39;, cap, s3d.at(s3d.group(39;bolts39;, bolts), z=cap_h-1))
cap_group = s3d.at(cap_group, y=post_y, z=cap_z)
bar = s3d.at(s3d.cylinder(&class="tok-comment">#39;crossbar39;, d=bar_d, h=bar_l), y=post_y+post_d/2, z=115, rx=-90)
outline = s3d.poly([(-knee,0),(heel,0),(heel,knee),(back,knee),(back,knee+cheek_t),(slope_start,plate_h),(front,plate_h),(front,support_z),(-12,back),(-7,post_d/2),(-16,post_d/2)])
cheek = s3d.at(s3d.extrude(&class="tok-comment">#39;cheek39;, outline, h=cheek_t), x=cheek_span/2-cheek_t, y=plate_y, rx=90, rz=90)
twin = s3d.transform(s3d.copy(cheek), mirror=&class="tok-comment">#39;x39;)
block = s3d.at(s3d.box(&class="tok-comment">#39;screw_support39;, w=post_w, d=support_d, h=support_h), y=screw_y, z=support_z)
ledge = s3d.at(s3d.box(&class="tok-comment">#39;rear_bridge39;, w=cheek_span, d=9, h=heel+3), y=-7, z=5)
pivot = s3d.at(s3d.cylinder(&class="tok-comment">#39;pivot_washer39;, d=24, h=3), x=-cheek_span/2-1, y=-61, z=80, ry=-90)
pivot_head = s3d.at(s3d.extrude(&class="tok-comment">#39;pivot_head39;, s3d.polygon(n=6, d=20), h=6), x=-cheek_span/2-3, y=-61, z=80, ry=-90)
pivot_twin = s3d.transform(s3d.copy(pivot), mirror=&class="tok-comment">#39;x39;)
head_twin = s3d.transform(s3d.copy(pivot_head), mirror=&class="tok-comment">#39;x39;)
solids = s3d.group(&class="tok-comment">#39;frame_solids39;, post, cap_group, bar, cheek, twin, block, ledge, pivot, pivot_head, pivot_twin, head_twin)
s3d.material(solids, kind=&class="tok-comment">#39;steelclass="tok-string">39;, color=39;#62686a39;)
claw = s3d.at(curved_claw(), x=-1, y=-102, z=9)
leg = s3d.at(sliding_leg(), x=-0.5, y=-48, z=-bottom)
spindle = s3d.at(post_screw(), x=-0.5, y=post_y, z=125)
screw = s3d.at(claw_screw(), y=screw_y, z=cheek_span)
root = s3d.group(&class="tok-comment">#39;clamp_frame39;, solids, claw, leg, spindle, screw)
s3d.joint(&class="tok-comment">#39;joint_claw_01_joint_00class="tok-string">39;, claw, s3d.local(root, x=0, y=-61, z=80), kind=39;revoluteclass="tok-string">39;, axis=39;+X39;, range=(0,50))
s3d.joint(&class="tok-comment">#39;joint_leg_01_joint_00class="tok-string">39;, leg, s3d.local(root, x=-1, y=-33, z=-79), kind=39;prismaticclass="tok-string">39;, axis=39;+Z39;, range=(0,78.6))
s3d.joint(&class="tok-comment">#39;joint_legBolt_01_joint_00class="tok-string">39;, spindle, s3d.local(root, x=0, y=-30, z=183), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_clawBolt_01_joint_00class="tok-string">39;, screw, s3d.local(root, x=0, y=-87, z=197), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
return root
def curved_claw(w=32, d=104, h=84, tip=15, arch=30):
profile = s3d.poly([(-d/2+tip,0),(-d/2+tip*2,3),(-d/2+arch,arch),(-tip,45),(-2,50),(29,48),(d/2,65),(d/2,h),(25,72),(-12,74),(-39,63),(-d/2,39)])
jaw = s3d.at(s3d.extrude(&class="tok-comment">#39;curved_jaw39;, profile, h=w), x=-w/2, rx=90, rz=90)
s3d.material(jaw, kind=&class="tok-comment">#39;steelclass="tok-string">39;, color=39;#555d6039;)
return s3d.group(&class="tok-comment">#39;curved_claw39;, jaw)
def sliding_leg(w=40, d=72, h=171, post_d=36, toe_h=18, recess=5, lip=4):
low = leg_section(w=w, d=post_d, recess=0, lip=lip)
high = leg_section(w=w, d=post_d, recess=w/2-lip/2, lip=lip)
shaft = s3d.loft(&class="tok-comment">#39;lower_post39;, low, s3d.at(high, z=h))
shaft = s3d.at(shaft, y=(d-post_d)/2)
profile = s3d.poly([(-d/2,0),(d/2,0),(d/2,toe_h),(-d/2+24,toe_h)])
foot = s3d.at(s3d.extrude(&class="tok-comment">#39;sloping_foot39;, profile, h=w), x=-w/2, rx=90, rz=90)
leg = s3d.join(shaft, foot)
s3d.material(leg, kind=&class="tok-comment">#39;steelclass="tok-string">39;, color=39;#646b6e39;)
return s3d.group(&class="tok-comment">#39;sliding_leg39;, leg)
def leg_section(w, d, recess, lip):
return s3d.poly([(-w/2,-d/2),(w/2,-d/2),(w/2,-d/2+lip),(w/2-recess,-d/2+lip*2),(w/2-recess,d/2-lip*2),(w/2,d/2-lip),(w/2,d/2),(-w/2,d/2),(-w/2,d/2-lip),(-w/2+recess,d/2-lip*2),(-w/2+recess,-d/2+lip*2),(-w/2,-d/2+lip)])
def post_screw(d=16, h=117, head_d=23, head_h=29, collar_h=5):
shaft = s3d.cylinder(&class="tok-comment">#39;spindle39;, d=d, h=h-head_h)
collar = s3d.at(s3d.cylinder(&class="tok-comment">#39;collar39;, d=head_d, h=collar_h), z=h-head_h-collar_h)
head = s3d.at(s3d.extrude(&class="tok-comment">#39;hex_head39;, s3d.polygon(n=6, d=head_d), h=head_h), z=h-head_h)
screw = s3d.join(shaft, collar, head)
s3d.material(screw, kind=&class="tok-comment">#39;steelclass="tok-string">39;, color=39;#757b7d39;)
return s3d.group(&class="tok-comment">#39;post_screw39;, screw)
def claw_screw(d=17, h=116, head_d=24, head_h=29, collar_h=5, pitch=3):
shaft = s3d.thread(&class="tok-comment">#39;threaded_shaft39;, d=d, length=h-head_h, pitch=pitch)
collar = s3d.at(s3d.cylinder(&class="tok-comment">#39;collar39;, d=head_d, h=collar_h), z=h-head_h-collar_h)
head = s3d.at(s3d.extrude(&class="tok-comment">#39;hex_head39;, s3d.polygon(n=6, d=head_d), h=head_h), z=h-head_h)
screw = s3d.group(&class="tok-comment">#39;claw_screw39;, shaft, collar, head)
s3d.material(screw, kind=&class="tok-comment">#39;steelclass="tok-string">39;, color=39;#777c7e39;)
return screw