import sand3d as s3d
def drill():
root=s3d.at(body_01(),x=-1,y=-17,z=0)
return s3d.assembly(class="tok-string">"drill",root)
def body_01(mw=56,mz=197,rear=-79,front=79,bw=63,bd=107,bh=42,sh=73,gw=23,cap=18,roundness=3,grip_d=40,grip_low=100,grip_high=148,saddle_z=158,saddle_d=94,strip_w=36,strip_d=82,strip_z=220,latch_d=43,latch_z=49,lip=4,rail_w=5,slope=13):
motor=s3d.at(s3d.cylinder(class="tok-string">"motor",d=mw,h=front-rear-cap),rx=-90,y=rear+cap,z=mz)
end=s3d.at(s3d.dome(class="tok-string">"rear_cap",d=mw,h=cap),rx=90,y=rear+cap+1,z=mz)
s3d.join(motor,end)
ref=s3d.group(class="tok-string">"housing_frame",motor)
vents=s3d.at(s3d.box(class="tok-string">"vent_tool",w=mw+2,d=2,h=lip),on=s3d.grid(nx=1,ny=lip,py=lip*2,on=s3d.local(ref,y=rear+lip,z=mz,rx=90)))
s3d.cut(motor,vents)
s3d.pocket(motor,s3d.slot(l=cap,d=2),depth=lip,on=s3d.grid(nx=1,ny=lip,py=lip*2,on=s3d.local(ref,x=mw/2,y=rear+cap/2,z=mz,rx=90,rz=90)))
s3d.pocket(motor,s3d.slot(l=cap,d=2),depth=lip,on=s3d.grid(nx=1,ny=lip,py=lip*2,on=s3d.local(ref,x=-mw/2,y=rear+cap/2,z=mz,rx=90,rz=-90)))
scallops=s3d.at(s3d.cylinder(class="tok-string">"scallop_tool",d=rail_w*2,h=cap),on=s3d.ring(n=10,r=mw/2+lip,on=s3d.local(ref,y=front-cap-2,z=mz,rx=-90)))
s3d.cut(motor,scallops)
rail=s3d.at(s3d.box(class="tok-string">"housing_rail",w=rail_w,d=latch_d,h=lip),x=gw,y=-2,z=strip_z-rail_w)
rail_image=s3d.transform(s3d.copy(rail),mirror=class="tok-string">"x")
bottom_rail=s3d.at(s3d.box(class="tok-string">"lower_rail",w=rail_w,d=latch_d,h=lip),x=gw,y=-2,z=mz-cap)
bottom_image=s3d.transform(s3d.copy(bottom_rail),mirror=class="tok-string">"x")
battery=s3d.at(s3d.extrude(class="tok-string">"battery",s3d.rect(w=bw-rail_w,d=bd,r=lip*2),h=bh),y=cap)
s3d.chamfer(battery,d=lip,edges=class="tok-string">"bottom")
guards=s3d.at(s3d.box(class="tok-string">"battery_guard",w=rail_w,d=lip*2,h=bh),on=s3d.grid(nx=2,ny=2,px=bw-rail_w,py=bd-cap),y=cap)
shoulder=s3d.loft(class="tok-string">"shoulder",s3d.station(z=bh-1,w=bw-lip,d=bd-lip,y=cap,n=roundness),s3d.station(z=bh+slope,w=bw-rail_w,d=strip_d,y=cap,n=roundness),s3d.station(z=sh,w=strip_w+2,d=bw-2,y=roundness,n=lip))
grip=s3d.loft(class="tok-string">"grip",s3d.station(z=sh-1,w=gw+lip,d=strip_w,y=-roundness,n=roundness),s3d.station(z=grip_low,w=gw,d=grip_d,y=0,n=2),s3d.station(z=(grip_low+grip_high)/2,w=gw,d=grip_d+lip,y=roundness,n=2),s3d.station(z=grip_high,w=gw,d=mw-cap/roundness,y=cap*2/roundness,n=roundness),s3d.station(z=saddle_z+cap/roundness,w=gw,d=saddle_d,y=cap/2,n=roundness))
saddle=s3d.at(s3d.extrude(class="tok-string">"saddle",s3d.ellipse(w=gw+cap/roundness,d=saddle_d),h=cap*2/roundness+1),y=cap/2,z=saddle_z)
strip=s3d.at(s3d.extrude(class="tok-string">"top_strip",s3d.rect(w=strip_w,d=strip_d,r=lip),h=rail_w),y=-slope,z=strip_z)
latch=s3d.at(s3d.extrude(class="tok-string">"battery_latch",s3d.rect(w=bw,d=latch_d,r=lip),h=cap/2),y=-2,z=latch_z)
s3d.material(motor,class="tok-string">"plastic",color=class="tok-string">"class="tok-comment">#d5a521")
s3d.join(motor,grip,shoulder,battery,guards,strip,latch,saddle,rail,rail_image,bottom_rail,bottom_image)
parent=s3d.group(class="tok-string">"body_01",motor)
s3d.pocket(motor,s3d.slot(l=latch_d-lip*2,d=cap/roundness),depth=2,on=s3d.local(parent,x=bw/2,y=-2,z=latch_z+lip,rx=90,rz=90))
s3d.pocket(motor,s3d.slot(l=latch_d-lip*2,d=cap/roundness),depth=2,on=s3d.local(parent,x=-bw/2,y=-2,z=latch_z+lip,rx=90,rz=-90))
s3d.pocket(motor,s3d.slot(l=slope,d=rail_w),depth=mw,on=s3d.local(parent,x=mw/2,y=gw,z=saddle_z+roundness,rx=90,rz=90))
direction=s3d.at(button_01(),x=0,y=gw+0.5,z=saddle_z+1)
chuck=s3d.at(chuck_01(),x=0,y=front,z=mz-cap-cap/roundness)
trigger=s3d.at(button_02(),x=0,y=grip_d+0.5,z=grip_high-cap+roundness)
selector=s3d.at(selector_01(),x=0,y=-grip_d/2+0.5,z=strip_z+lip)
s3d.seat(motor,trigger)
s3d.joint(class="tok-string">"joint_button_01_joint_00",direction,s3d.local(parent,x=0,y=23,z=162),kind=class="tok-string">"prismatic",axis=class="tok-string">"-X",range=(-3,3))
s3d.joint(class="tok-string">"joint_chuck_01_joint_00",chuck,s3d.local(parent,x=0,y=79,z=197),kind=class="tok-string">"continuous",axis=class="tok-string">"+Y")
s3d.joint(class="tok-string">"joint_button_02_joint_00",trigger,s3d.local(parent,x=0,y=28,z=160),kind=class="tok-string">"prismatic",axis=class="tok-string">"+Y",range=(-3.6,0))
s3d.joint(class="tok-string">"joint_selector_01_joint_00",selector,s3d.local(parent,x=0,y=-20,z=225),kind=class="tok-string">"prismatic",axis=class="tok-string">"+Y",range=(-5,5))
return s3d.group(class="tok-string">"body_01_group",parent,direction,chuck,trigger,selector)
def button_01(w=29,d=13,h=5):
ob=s3d.box(class="tok-string">"direction",w=w,d=d,h=h)
s3d.material(ob,class="tok-string">"plastic",color=class="tok-string">"class="tok-comment">#bd3425")
return s3d.group(class="tok-string">"button_01",ob)
def chuck_01(d=45,sleeve_l=28,nose_d=37,nose_l=20,bit_d=6,bit_l=20,axis_z=24):
sleeve=s3d.at(s3d.cylinder(class="tok-string">"sleeve",d=d,h=sleeve_l),rx=-90,z=axis_z)
nose=s3d.at(s3d.cylinder(class="tok-string">"nose",d=nose_d,h=nose_l),rx=-90,y=sleeve_l-1,z=axis_z)
bit=s3d.at(s3d.cylinder(class="tok-string">"bit",d=bit_d,h=bit_l),rx=-90,y=sleeve_l+nose_l-1,z=axis_z)
s3d.fillet(nose,r=3,edges=class="tok-string">"top")
s3d.material(sleeve,class="tok-string">"rubber",color=class="tok-string">"class="tok-comment">#282a2d")
s3d.material(nose,class="tok-string">"steel",color=class="tok-string">"class="tok-comment">#62676c")
s3d.material(bit,class="tok-string">"steel",color=class="tok-string">"class="tok-comment">#979ca1")
return s3d.group(class="tok-string">"chuck_01",sleeve,nose,bit)
def button_02(w=17,d=21,h=24,inset=7,t=3):
profile=s3d.poly([(-d/2,0),(d/2-inset,0),s3d.spline([(d/2-inset,h/4),(d/2-inset-t,h/2),(d/2-inset,h-t*2),(d/2,h-t)]),(d/2,h),(-d/2,h)])
ob=s3d.at(s3d.extrude(class="tok-string">"trigger",profile,h=w),rx=90,rz=90,x=-w/2)
s3d.material(ob,class="tok-string">"plastic",color=class="tok-string">"class="tok-comment">#25282b")
return s3d.group(class="tok-string">"button_02",ob)
def selector_01(w=20,d=37,h=4):
ob=s3d.box(class="tok-string">"selector",w=w,d=d,h=h)
s3d.fillet(ob,r=1)
s3d.material(ob,class="tok-string">"plastic",color=class="tok-string">"class="tok-comment">#292c30")
return s3d.group(class="tok-string">"selector_01",ob)