import sand3d as s3d
def detector():
root=s3d.at(detector_body(),x=15.74,y=16.61)
return s3d.assembly(&class="tok-comment">#39;detector39;,root)
def detector_body(cx=15.74,cy=16.61,yc=47,h=30,cable_d=7,probe_d=12):
housing=s3d.body(&class="tok-comment">#39;housing39;,plan=[(-62,56),(-57,75),(-25,84),(5,83),(45,70),(90,56),(150,54),(161,48)],top=h,bottom=0,n=8)
housing=s3d.at(housing,x=-cx,y=yc-cy,rz=-90)
s3d.material(housing,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#343a3e39;)
screen=s3d.at(s3d.extrude(&class="tok-comment">#39;display_rim39;,s3d.rect(w=69,d=60,r=5),h=1),x=-16-cx,y=yc-cy,z=h-1)
s3d.pocket(screen,s3d.rect(w=65,d=56,r=3),depth=0.6,on=screen.face(&class="tok-comment">#39;top39;))
s3d.material(screen,&class="tok-comment">#39;glassclass="tok-string">39;,color=39;#697b7939;,roughness=0.3)
path=s3d.spline([(-62-cx,yc-cy,h/2),(-105-cx,40-cy,h/2),(-126-cx,8-cy,h/2),(-94-cx,-29-cy,h/2)],tangents=((-1,0,0),(1,0,0)))
cable=s3d.wire(&class="tok-comment">#39;cable_curve39;,path=path,d=cable_d)
straight=[(-94-cx,-29-cy,h/2),(120-cx,-29-cy,h/2)]
lead=s3d.wire(&class="tok-comment">#39;cable_straight39;,path=straight,d=cable_d)
s3d.material(cable,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#25282b39;)
s3d.material(lead,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#25282b39;)
rib=s3d.at(s3d.torus(&class="tok-comment">#39;cord_rib39;,d=cable_d,d_wire=1.4),z=-0.7)
s3d.material(rib,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#25282b39;)
ribs=s3d.at(rib,on=s3d.along(path,pitch=4))
rib2=s3d.at(s3d.torus(&class="tok-comment">#39;straight_rib39;,d=cable_d,d_wire=1.4),z=-0.7)
s3d.material(rib2,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#25282b39;)
ribs2=s3d.at(rib2,on=s3d.along(straight,pitch=4))
probe=s3d.at(s3d.cylinder(&class="tok-comment">#39;probe39;,d=probe_d,h=25),x=104-cx,y=-29-cy,z=h/2,ry=90)
tip=s3d.at(s3d.cone(&class="tok-comment">#39;tip39;,d=probe_d,h=16,d2=2),x=129-cx,y=-29-cy,z=h/2,ry=90)
s3d.material(probe,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#353b3e39;)
s3d.material(tip,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#999da039;)
bar=s3d.at(s3d.cylinder(&class="tok-comment">#39;parallel_bar39;,d=cable_d,h=62),x=43-cx,y=-40-cy,z=h/2,ry=90)
s3d.material(bar,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#353b3e39;)
loop=s3d.wire(&class="tok-comment">#39;hanging_loop39;,path=s3d.spline([(35-cx,-39-cy,h/2),(25-cx,-55-cy,2),(15-cx,-48-cy,5),(20-cx,-39-cy,h/2)]),d=1)
s3d.material(loop,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#999da039;)
b2=s3d.at(button_02(),x=41.5-cx,y=59-cy,z=27)
b4=s3d.at(button_04(),x=25-cx,y=34-cy,z=27)
b3=s3d.at(button_03(),x=41.5-cx,y=34.5-cy,z=27)
b1=s3d.at(button_01(),x=25-cx,y=59.5-cy,z=27)
b5=s3d.at(button_05(),x=33-cx,y=47-cy,z=27)
root=s3d.group(&class="tok-comment">#39;detector_body39;,housing,screen,cable,lead,ribs,ribs2,probe,tip,bar,loop,b2,b4,b3,b1,b5)
s3d.joint(&class="tok-comment">#39;joint_button_02_joint_00class="tok-string">39;,b2,on=s3d.local(root,x=25.26,y=42.39,z=30),kind=39;prismaticclass="tok-string">39;,axis=39;+Z39;,range=(-1.8,0))
s3d.joint(&class="tok-comment">#39;joint_button_04_joint_00class="tok-string">39;,b4,on=s3d.local(root,x=8.26,y=16.39,z=30),kind=39;prismaticclass="tok-string">39;,axis=39;+Z39;,range=(-1.8,0))
s3d.joint(&class="tok-comment">#39;joint_button_03_joint_00class="tok-string">39;,b3,on=s3d.local(root,x=25.26,y=18.39,z=30),kind=39;prismaticclass="tok-string">39;,axis=39;+Z39;,range=(-1.8,0))
s3d.joint(&class="tok-comment">#39;joint_button_01_joint_00class="tok-string">39;,b1,on=s3d.local(root,x=8.26,y=44.39,z=30),kind=39;prismaticclass="tok-string">39;,axis=39;+Z39;,range=(-1.8,0))
s3d.joint(&class="tok-comment">#39;joint_button_05_joint_00class="tok-string">39;,b5,on=s3d.local(root,x=17.26,y=30.39,z=30),kind=39;prismaticclass="tok-string">39;,axis=39;+Z39;,range=(-1.8,0))
return root
def button_02(w=13,d=20,h=4):
p=s3d.poly([(-w/2,d/2),(-w/2,-1),s3d.spline([(-w/2,-1),(0,-5),(w/2-3,-d/2),(w/2,-d/2),(w/2-1,0),(0,d/2-2)])],fillet=1)
ob=s3d.at(s3d.extrude(&class="tok-comment">#39;button_0239;,p,h=h/2),z=h/2)
s3d.material(ob,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#45515b39;)
return s3d.group(&class="tok-comment">#39;button_0239;,ob)
def button_04(w=12,d=22,h=4):
ob=s3d.extrude(&class="tok-comment">#39;button_0439;,s3d.rect(w=w,d=d,r=2),h=h/2)
tool=s3d.at(s3d.cylinder(&class="tok-comment">#39;disc_clearance39;,d=23,h=h),x=8,y=13)
ob=s3d.at(s3d.cut(ob,tool),z=h/2)
s3d.material(ob,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#45515b39;)
return s3d.group(&class="tok-comment">#39;button_0439;,ob)
def button_03(w=13,d=21,h=4):
p=s3d.poly([(-w/2,-d/2),s3d.spline([(-w/2,-d/2),(0,-7),(w/2-2,0),(w/2,d/2-2),(w/2-1,d/2),(2,d/2),(-1,5),(-w/2,2)])],fillet=1)
ob=s3d.at(s3d.extrude(&class="tok-comment">#39;button_0339;,p,h=h/2),z=h/2)
s3d.material(ob,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#45515b39;)
return s3d.group(&class="tok-comment">#39;button_0339;,ob)
def button_01(w=12,d=21,h=4):
ob=s3d.extrude(&class="tok-comment">#39;button_0139;,s3d.rect(w=w,d=d,r=2),h=h/2)
tool=s3d.at(s3d.cylinder(&class="tok-comment">#39;disc_clearance39;,d=23,h=h),x=8,y=-12.5)
ob=s3d.at(s3d.cut(ob,tool),z=h/2)
s3d.material(ob,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#45515b39;)
return s3d.group(&class="tok-comment">#39;button_0139;,ob)
def button_05(w=16,d=16,h=4):
ob=s3d.at(s3d.cylinder(&class="tok-comment">#39;button_0539;,d=w,h=h/2),z=h/2)
s3d.chamfer(ob,d=0.6,edges=&class="tok-comment">#39;top39;)
s3d.material(ob,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#45515b39;)
return s3d.group(&class="tok-comment">#39;button_0539;,ob)