import sand3d as s3d
def fork():
grip = s3d.at(handle(), y=-56.6, z=5.5)
head = s3d.at(fork_head(), y=42.9, z=0.2)
return s3d.assembly(class="tok-string">"fork", grip, head)
def handle(w=15, d=125, h=14, neck_w=11, neck_h=10, cap=7, center_z=7):
sections = [s3d.station(z=0, w=0.8, d=0.8), s3d.station(z=cap/4, w=neck_w*0.65, d=neck_h*0.65), s3d.station(z=cap/2, w=neck_w*0.9, d=neck_h*0.9), s3d.station(z=cap, w=neck_w, d=neck_h)]
for f in (0.25, 0.5, 0.75, 1):
sections.append(s3d.station(z=cap+(d-2*cap)*f, w=neck_w+(w-neck_w)*f, d=neck_h+(h-neck_h)*f))
sections.extend([s3d.station(z=d-cap/2, w=w*0.87, d=h*0.87), s3d.station(z=d-cap/6, w=w*0.5, d=h*0.5), s3d.station(z=d, w=0.6, d=0.6)])
grip = s3d.loft(class="tok-string">"grip", *sections)
grip = s3d.at(grip, rx=90, y=d/2-2, z=center_z)
s3d.material(grip, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#dedbd1", roughness=0.3)
return s3d.group(class="tok-string">"handle", grip)
def fork_head(w=25, d=73, h=23.1, t=1.2, bowl_y=33, split_y=39, end_y=79, neck_y=1, neck_z=12, tine_pitch=8.5, tine_w=7):
y0 = -42.9
z0 = -0.2
base = s3d.body(class="tok-string">"neck_and_bowl", plan=[(neck_y+y0,10), (13+y0,12), (23+y0,18), (bowl_y+y0,w), (split_y+y0,w)], top=[(neck_y+y0,neck_z+z0+t/2), (13+y0,11+z0), (23+y0,5+z0), (bowl_y+y0,t*1.5+z0), (split_y+y0,3+z0)], bottom=[(neck_y+y0,neck_z+z0-t/2), (13+y0,11+z0-t), (23+y0,5+z0-t), (bowl_y+y0,t/2+z0), (split_y+y0,3+z0-t)], n=8)
tine = s3d.body(class="tok-string">"tine", plan=[(split_y+y0-1,tine_w), (56+y0,5.7), (74+y0,3), (end_y+y0,0.1)], top=[(split_y+y0-1,2.5+z0), (end_y+y0,h)], bottom=[(split_y+y0-1,2.5+z0-t), (end_y+y0,h+z0)], n=8)
tines = s3d.at(tine, on=s3d.grid(nx=3, px=tine_pitch))
s3d.join(base, tines)
s3d.material(base, class="tok-string">"steel", color=class="tok-string">"class="tok-comment">#b5b7b8", roughness=0.24)
return s3d.group(class="tok-string">"fork_head", base)