import sand3d as s3d
def sunvisor():
mount = s3d.at(pivot_mount(), x=-10, y=150.5, z=105)
panel = s3d.at(visor_panel(), x=-0.5, y=15, z=0)
s3d.joint(&class="tok-comment">#39;joint_frame_01_joint_00class="tok-string">39;, panel, s3d.local(mount, x=10, y=-22, z=24), kind=39;revoluteclass="tok-string">39;, axis=39;+Y39;, range=(-140,15))
return s3d.assembly(&class="tok-comment">#39;sunvisor39;, mount, panel)
def pivot_mount(w=28, d=45, h=49, plate_t=3, plate_d=25, arm_d=7):
plate = s3d.extrude(&class="tok-comment">#39;mount_plate39;, s3d.rect(plate_d,h,r=10), h=plate_t)
plate = s3d.at(plate, x=-7, z=h/2, rx=90, rz=90, y=d/2-plate_d/2)
rim = s3d.extrude(&class="tok-comment">#39;raised_rim39;, s3d.rect(plate_d,h,r=10), h=plate_t)
rim = s3d.pocket(rim, s3d.rect(plate_d-4,h-4,r=8), depth=plate_t-1)
rim = s3d.at(rim, x=-10, y=d/2-plate_d/2,z=h/2,rx=90,rz=90)
arm = s3d.wire(&class="tok-comment">#39;curved_arm39;, s3d.spline([(10,-d/2,24),(10,0,24),(5,9,24),(-7,9,24)]), d=arm_d)
hub = s3d.at(s3d.cylinder(&class="tok-comment">#39;plate_hub39;, d=10, h=6), x=-13,y=9,z=24,ry=90)
part = s3d.group(&class="tok-comment">#39;pivot_mount39;,plate,rim,arm,hub)
s3d.material(part,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#77777339;)
return part
def visor_panel(w=15, d=378, h=145, rounding=6, recess_d=152, recess_h=75, recess_y=76, recess_z=60):
outline = s3d.poly([(-d/2,30),(-d/2,h),(-166,h),(-162,125),(-139,125),(-122,h),(115,h),(124,122),(d/2,114),(d/2,35),(162,0),(-166,0)],fillet=12)
solid = s3d.extrude(&class="tok-comment">#39;padded_panel39;, outline, h=w, both=True)
solid = s3d.fillet(solid,r=rounding,edges=&class="tok-comment">#39;top bottom39;)
solid = s3d.at(solid,rx=90,rz=90,x=0.5)
tool = s3d.extrude(&class="tok-comment">#39;recess39;,s3d.rect(recess_d,recess_h,r=5),h=4)
tool = s3d.at(tool,x=-w/2-1,y=recess_y,z=recess_z,rx=90,rz=90)
solid = s3d.cut(solid,tool)
tab = s3d.extrude(&class="tok-comment">#39;tab39;,s3d.rect(27,30,r=4),h=2)
tab = s3d.at(tab,x=-w/2-1,y=recess_y-recess_d/2-16,z=recess_z+9,rx=90,rz=90)
s3d.material(solid,&class="tok-comment">#39;fabricclass="tok-string">39;,color=39;#92918b39;)
s3d.material(tab,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#88878039;)
cover = s3d.at(sliding_cover(),x=-5,y=76,z=25)
clip = s3d.at(retaining_clip(),x=-5,y=-149.5,z=107)
panel = s3d.group(&class="tok-comment">#39;visor_panel39;,solid,tab,cover,clip)
s3d.joint(&class="tok-comment">#39;joint_cover_01_joint_00class="tok-string">39;,cover,s3d.local(panel,x=-3,y=140,z=60),kind=39;prismaticclass="tok-string">39;,axis=39;+Y39;,range=(-129.8,0))
s3d.joint(&class="tok-comment">#39;joint_attachment_01_joint_00class="tok-string">39;,clip,s3d.local(panel,x=1,y=-150,z=135),kind=39;revoluteclass="tok-string">39;,axis=39;+Y39;,range=(0,150))
return panel
def sliding_cover(w=3, d=148, h=71, grip_h=50, grip_d=4):
plate = s3d.extrude(&class="tok-comment">#39;sliding_shutter39;,s3d.rect(d,h,r=4),h=w)
plate = s3d.at(plate,x=-w/2,z=h/2,rx=90,rz=90)
grip = s3d.box(&class="tok-comment">#39;grip39;,w,grip_d,grip_h)
grip = s3d.at(grip,x=-w/2,y=d/2-10,z=(h-grip_h)/2)
part = s3d.group(&class="tok-comment">#39;sliding_cover39;,plate,grip)
s3d.material(part,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#85847f39;)
return part
def retaining_clip(w=25, d=15, h=36, t=1.5, slope=9):
profile = s3d.poly([(-w/2,0),(-w/2,h),(w/2,h),(w/2,h-5),(w/2-slope,h-5),(-w/2+7,0)],fillet=2)
outer = s3d.extrude(&class="tok-comment">#39;clip_shell39;,profile,h=d)
outer = s3d.at(outer,y=d/2,rx=90)
cavity = s3d.poly([(-w/2-t,t),(-w/2-t,h-t),(w/2-t,h-t),(w/2-slope-t,h-5-t),(-w/2+7-t,t)],fillet=1)
opening = s3d.extrude(&class="tok-comment">#39;clip_gap39;,cavity,h=d-2*t)
opening = s3d.at(opening,y=(d-2*t)/2,rx=90)
outer = s3d.cut(outer,opening)
s3d.material(outer,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#55565039;)
return s3d.group(&class="tok-comment">#39;retaining_clip39;,outer)