import sand3d as s3d
def controller():
body=s3d.at(controller_body(),x=-14.5,y=-42.9,z=0)
a=s3d.at(auxiliary_button(),x=5,y=12.5,z=60)
b=s3d.at(negative_y_wedge(),x=6,y=-11.5,z=30)
c=s3d.at(upper_wedge(),x=5,y=-0.5,z=48)
d=s3d.at(lower_wedge(),x=5,y=-0.5,z=25)
e=s3d.at(positive_y_wedge(),x=6,y=11,z=30)
f=s3d.at(primary_button(),x=5,y=-13,z=60)
s3d.joint(&class="tok-comment">#39;joint_button_06_joint_00class="tok-string">39;,a,on=s3d.local(body,x=25.5,y=55.4,z=65),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(0,0.001))
s3d.joint(&class="tok-comment">#39;joint_button_02_joint_00class="tok-string">39;,b,on=s3d.local(body,x=25.5,y=29.9,z=42),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(0,0.001))
s3d.joint(&class="tok-comment">#39;joint_button_03_joint_00class="tok-string">39;,c,on=s3d.local(body,x=25.5,y=42.9,z=55),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(-1,0))
s3d.joint(&class="tok-comment">#39;joint_button_01_joint_00class="tok-string">39;,d,on=s3d.local(body,x=25.5,y=42.9,z=29),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(-1,0))
s3d.joint(&class="tok-comment">#39;joint_button_04_joint_00class="tok-string">39;,e,on=s3d.local(body,x=25.5,y=55.9,z=42),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(0,0.001))
s3d.joint(&class="tok-comment">#39;joint_button_05_joint_00class="tok-string">39;,f,on=s3d.local(body,x=25.5,y=29.9,z=65),kind=39;prismaticclass="tok-string">39;,axis=39;+X39;,range=(0,0.001))
return s3d.assembly(&class="tok-comment">#39;controller39;,body,a,b,c,d,e,f)
def controller_body(t=19,lower=67,upper=82,h=131,step=65,corner=9,panel_w=61,panel_h=48,panel_z=96,cable_d=6.5,plug_l=62,plug_w=39,plug_h=19,plug_y=-100):
p=s3d.poly([(-lower/2,0),(lower/2,0),(lower/2,step),(upper/2,step+corner),(upper/2,h),(-upper/2,h),(-upper/2,step+corner),(-lower/2,step)],fillet=corner)
shell=s3d.at(s3d.extrude(&class="tok-comment">#39;housing39;,p,h=t),x=1-t/2,rx=90,rz=90)
s3d.fillet(shell,r=corner*2/3)
keypad=s3d.at(s3d.extrude(&class="tok-comment">#39;keypad_recess39;,s3d.rect(lower-corner*5/3,step-corner,r=corner/2),h=t),x=corner*2/3,z=step/2+corner*4/3,rx=90,rz=90)
well=s3d.extrude(&class="tok-comment">#39;control_well39;,s3d.rect(corner*4,corner*4,r=corner),h=t)
cross=s3d.at(s3d.extrude(&class="tok-comment">#39;diagonal_gap39;,s3d.rect(corner/3,corner*6),h=t+2),z=-1,rz=45)
twin=s3d.transform(s3d.copy(cross),mirror=&class="tok-comment">#39;x39;)
well=s3d.cut(well,cross,twin)
well=s3d.at(well,z=step-corner*5/2,rx=90,rz=90)
display_cut=s3d.at(s3d.extrude(&class="tok-comment">#39;display_recess39;,s3d.rect(panel_w+2,panel_h+2,r=3),h=corner),x=corner/3,z=panel_z,rx=90,rz=90)
shell=s3d.cut(shell,keypad,well,display_cut)
for i in range(3):
cutter=s3d.at(s3d.box(&class="tok-comment">#39;groove39;,t*2,corner/2,corner/3),y=lower/2,z=step/2-corner/3+i*corner*5/6)
twin=s3d.transform(s3d.copy(cutter),mirror=&class="tok-comment">#39;y39;)
shell=s3d.cut(shell,cutter,twin)
glass=s3d.at(s3d.extrude(&class="tok-comment">#39;display39;,s3d.rect(panel_w,panel_h,r=3),h=cable_d),x=corner/2,z=panel_z,rx=90,rz=90)
back=s3d.at(s3d.extrude(&class="tok-comment">#39;back_panel39;,s3d.offset(p,t=-corner-2),h=corner/2+1),x=-t/2-corner/3,rx=90,rz=90)
shell=s3d.join(shell,back)
ribs=[]
for i in range(11):
ribs.append(s3d.at(s3d.box(&class="tok-comment">#39;back_rib39;,2,panel_w/2,2),x=-t/2-corner/2,z=plug_h+corner+i*(h-corner*5)/10))
collar=s3d.at(s3d.cylinder(&class="tok-comment">#39;collar39;,d=corner*5/3,h=corner),z=h-1)
collar2=s3d.at(s3d.cone(&class="tok-comment">#39;strain_relief39;,d=corner*4/3,h=corner,d2=corner),z=h+corner-2)
cable=s3d.wire(&class="tok-comment">#39;cable39;,s3d.spline([(0,0,h+14),(0,2,156),(-6,12,157),(-16,7,138),(-35,-14,96),(-55,-39,54),(-64,-60,26),(-53,-78,11),(-32,-86,10)]),d=cable_d)
plug=s3d.at(s3d.extrude(&class="tok-comment">#39;plug39;,s3d.poly([(-plug_l/2,-plug_w/3),(-plug_l/3,-plug_w/3),(-plug_l/6,-plug_w/2),(plug_l/2,-plug_w/2),(plug_l/2,plug_w/2),(-plug_l/6,plug_w/2),(-plug_l/3,plug_w/3),(-plug_l/2,plug_w/3)],fillet=3),h=plug_h),y=plug_y,rz=-20)
s3d.fillet(plug,r=2)
nose=s3d.at(s3d.box(&class="tok-comment">#39;nose39;,corner*4/3,plug_w-cable_d,plug_h*2/3),x=plug_l/2-corner/3,y=plug_y-corner,z=plug_h/6,rz=-20)
relief=s3d.cylinder(&class="tok-comment">#39;plug_relief39;,d=corner,h=corner*4/3)
for i in range(4):
ring=s3d.at(s3d.cylinder(&class="tok-comment">#39;relief_rib39;,d=corner+1,h=1),z=i*corner/3)
relief=s3d.join(relief,ring)
relief=s3d.at(relief,x=-plug_w,y=plug_y+plug_w/3,z=plug_h/2,ry=90,rz=-20)
root=s3d.group(&class="tok-comment">#39;body39;,shell,glass,ribs,collar,collar2,cable,plug,nose,relief)
s3d.material(root,kind=&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#34394039;)
s3d.material(glass,kind=&class="tok-comment">#39;glassclass="tok-string">39;,color=39;#26343b39;)
s3d.material(cable,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#20222639;)
return s3d.transform(root,x=14.5,y=42.9)
def auxiliary_button(w=6,d=9,h=10):
ob=s3d.at(s3d.extrude(&class="tok-comment">#39;button39;,s3d.rect(d,h,r=d/3),h=w),rx=90,rz=90,z=h/2)
s3d.material(ob,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#62696c39;)
return s3d.group(&class="tok-comment">#39;auxiliary_button39;,ob)
def negative_y_wedge(w=5,d=11,h=23):
ob=control_wedge(w=w,d=h,h=d,turn=90,lift=h/2)
return s3d.group(&class="tok-comment">#39;negative_y_wedge39;,ob)
def control_wedge(w=6,d=23,h=11,turn=0,lift=5.5):
p=s3d.poly([(-d/2,h/3),(-d/3,h/2),(d/3,h/2),(d/2,h/3),(d/6,-h/2),(-d/6,-h/2)],fillet=1)
ob=s3d.at(s3d.extrude(&class="tok-comment">#39;control39;,p,h=w),rx=90,rz=90)
s3d.material(ob,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#454b5039;)
return s3d.transform(ob,rx=turn,z=lift)
def upper_wedge(w=6,d=23,h=11):
ob=control_wedge(w=w,d=d,h=h,lift=h/2)
return s3d.group(&class="tok-comment">#39;upper_wedge39;,ob)
def lower_wedge(w=6,d=23,h=11):
ob=control_wedge(w=w,d=d,h=h,turn=180,lift=h/2)
return s3d.group(&class="tok-comment">#39;lower_wedge39;,ob)
def positive_y_wedge(w=5,d=11,h=23):
p=s3d.poly([(-d/2,h/3),(-d/2,h*2/3),(d/4,h),(d/2,h*5/6),(d/2,h/3),(d/3,h/12),(d/6,0)],fillet=1)
ob=s3d.at(s3d.extrude(&class="tok-comment">#39;control39;,p,h=w),rx=90,rz=90)
s3d.material(ob,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#454b5039;)
return s3d.group(&class="tok-comment">#39;positive_y_wedge39;,ob)
def primary_button(w=6,d=10,h=11):
ob=s3d.at(s3d.extrude(&class="tok-comment">#39;button39;,s3d.rect(d,h,r=d/3),h=w),rx=90,rz=90,z=h/2)
s3d.material(ob,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#62696c39;)
return s3d.group(&class="tok-comment">#39;primary_button39;,ob)