import sand3d as s3d
def welder():
root=s3d.at(welding_unit(),x=0,y=0,z=0)
handle=s3d.at(carrying_handle(),y=28.5,z=234)
button=s3d.at(rocker_button(),x=-165,y=51.5,z=155)
knob=s3d.at(current_switch(),x=170.5,y=-35.5,z=157)
mode=s3d.at(mode_switch(),x=170.5,y=35,z=157)
s3d.joint(&class="tok-comment">#39;joint_hanlde_01_joint_00class="tok-string">39;,handle,on=s3d.local(root,x=0,y=0,z=242),axis=39;+X39;,range=(0,179))
s3d.joint(&class="tok-comment">#39;joint_button_01_joint_00class="tok-string">39;,button,on=s3d.local(root,x=-164,y=51,z=168),axis=39;+Y39;,range=(0,43))
s3d.joint(&class="tok-comment">#39;joint_switch_01_joint_00class="tok-string">39;,knob,on=s3d.local(root,x=171,y=-36,z=170,ry=75.1),axis=39;normal39;,range=(-140,140))
s3d.joint(&class="tok-comment">#39;joint_switch_02_joint_00class="tok-string">39;,mode,on=s3d.local(root,x=171,y=36,z=170,ry=75.1),axis=39;normal39;,range=(-140,140))
return s3d.assembly(&class="tok-comment">#39;welder39;,root,handle,button,knob,mode)
def welding_unit(w=377,d=157,h=234,foot=14,shoulder=148,top_w=320,border=27,cable=7,feet_w=46,torch_x=-210,torch_y=195,torch_l=200,holder_x=293,holder_y=-202,holder_l=174,clamp_x=239,clamp_y=246,clamp_l=180,loop_x=360,loop_y=80,low_x=380,high_x=420,far_x=452,plug_x=-370,plug_y=-49,conn_x=230):
half=w/2
core=half-border/2
roof=top_w/2-border/2
skin=cable/2
profile=s3d.poly([(-core,foot),(core,foot),(core,shoulder),(roof,h-skin),(-roof,h-skin),(-core,shoulder)])
body=s3d.at(s3d.extrude(&class="tok-comment">#39;cabinet39;,profile,h=d-cable),y=(d-cable)/2,rx=90)
s3d.material(body,&class="tok-comment">#39;painted_metalclass="tok-string">39;,color=39;#254c6939;)
feet=s3d.at(s3d.box(&class="tok-comment">#39;feet39;,w=feet_w,d=d,h=foot+2),on=s3d.grid(nx=2,px=w-feet_w))
s3d.material(feet,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#22252a39;)
rim_profile=s3d.poly([(-half+foot/2,foot),(-half+foot/2,shoulder),(-top_w/2+foot/2,h),(-top_w/2+border,h),(-half+border,shoulder),(-half+border,foot)])
rim=s3d.at(s3d.extrude(&class="tok-comment">#39;end_border39;,rim_profile,h=d),y=d/2,rx=90)
s3d.material(rim,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#20272b39;)
twin=s3d.transform(s3d.copy(rim),mirror=&class="tok-comment">#39;x39;)
sockets=s3d.at(s3d.cylinder(&class="tok-comment">#39;connection39;,d=border,h=conn_x-core+skin+cable),on=s3d.grid(nx=1,ny=3,py=-plug_y),x=core-skin,z=h/2-foot,ry=90)
s3d.material(sockets,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#26272939;)
z=h/2-foot
floor=cable/2
paths=[]
paths.append([(conn_x,plug_y,z),(holder_x,plug_y,z),(low_x,plug_y+border,foot*2),(high_x,-loop_y,foot),(low_x,holder_y+feet_w,foot),(holder_x,holder_y+feet_w,floor),(holder_x-border,-loop_y-foot,floor),(holder_x,-loop_y,floor),(low_x,plug_y+border,floor),(far_x,-loop_y,floor),(high_x,holder_y,foot),(holder_x,holder_y,foot)])
paths.append([(conn_x,-plug_y,z),(clamp_x+foot,loop_y,z/2),(clamp_x+foot,torch_y-foot,foot*2),(torch_y,torch_y+border,foot*2),(torch_l/2,torch_y+border,foot*2),(0,torch_y-foot*2,foot*2),(border,torch_l/2,foot),(torch_l/2+border,torch_l/2,foot),(torch_l/2+feet_w,torch_y-foot,cable),(torch_l/2,torch_y+border,cable),(0,clamp_y,foot),(torch_x+torch_l/2,torch_y+border,foot),(torch_x+torch_l/2,torch_y,foot)])
paths.append([(-roof,-plug_y,h-foot),(-conn_x,border,h/2+feet_w),(-clamp_x-foot,plug_y,feet_w),(-holder_x,-loop_y-border,foot),(plug_x,-loop_y-feet_w,floor),(-low_x-foot,-loop_y,foot),(-low_x,plug_y,foot),(-top_w,foot,floor),(-top_w,loop_y,floor),(-loop_x,loop_y+border,floor),(-high_x,loop_y+border,floor),(-far_x,loop_y/2,foot),(-high_x,-foot,foot),(plug_x-feet_w/2,plug_y,foot)])
paths.append([(conn_x,0,z),(holder_x,foot,z),(loop_x,loop_y/2,foot),(loop_x+border,loop_y,foot),(loop_x,loop_y+border,foot),(holder_x+border,loop_y,foot),(loop_x,foot,foot),(low_x,0,foot),(high_x,loop_y,foot),(high_x,clamp_y,foot),(clamp_x,clamp_y+feet_w,foot),(clamp_x-clamp_l/2,clamp_y+feet_w-cable,foot)])
leads=[]
for i,pts in enumerate(paths):
lead=s3d.wire(&class="tok-comment">#39;lead39;,path=s3d.spline(pts),d=cable*2+skin if i==1 else cable)
s3d.material(lead,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#17191c39;)
leads.append(lead)
torch_h=feet_w-cable
torch=s3d.at(s3d.extrude(&class="tok-comment">#39;torch39;,s3d.rect(w=torch_h,d=foot*2,r=foot-cable/2),h=torch_l),x=torch_x-torch_l/2,y=torch_y-foot,z=torch_h/2,ry=90)
head=s3d.at(s3d.box(&class="tok-comment">#39;torch_head39;,w=foot,d=feet_w,h=foot*2),x=torch_x+torch_l/2-foot/2,y=torch_y,z=cable)
s3d.join(torch,head)
s3d.material(torch,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#272d3339;)
nozzle=s3d.wire(&class="tok-comment">#39;torch_tip39;,path=s3d.spline([(torch_x-torch_l/2,torch_y-foot,foot),(torch_x-torch_l/2-border,torch_y+skin,foot),(torch_x-torch_l/2-feet_w*2,torch_y+border,foot*2)]),d=cable)
s3d.material(nozzle,&class="tok-comment">#39;copperclass="tok-string">39;,color=39;#a47d5439;)
holder=s3d.at(s3d.extrude(&class="tok-comment">#39;electrode_holder39;,s3d.rect(w=holder_l,d=border,r=cable),h=border),x=holder_x,y=holder_y,z=0)
s3d.material(holder,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#26292b39;)
lever=s3d.wire(&class="tok-comment">#39;holder_lever39;,path=[(holder_x-foot,holder_y,foot*2),(holder_x+foot,holder_y,feet_w+foot),(holder_x+feet_w,holder_y,feet_w+foot*2)],d=cable*2)
s3d.material(lever,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#31353639;)
plug=s3d.at(s3d.cylinder(&class="tok-comment">#39;plug39;,d=border,h=feet_w*2),x=plug_x-feet_w/2,y=plug_y,z=foot+skin,ry=90)
s3d.material(plug,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#25282b39;)
trigger=s3d.at(s3d.box(&class="tok-comment">#39;plug_trigger39;,w=feet_w/2,d=cable,h=cable),x=plug_x+feet_w,y=plug_y,z=border)
s3d.material(trigger,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#292c3039;)
jaws=[]
for angle in (0,-24):
jaw=s3d.at(s3d.extrude(&class="tok-comment">#39;clamp_jaw39;,s3d.poly([(0,-skin),(border,-foot),(feet_w,-foot),(clamp_l,-skin),(clamp_l,skin),(feet_w,cable),(border,foot),(0,skin)]),h=cable*2),x=clamp_x-clamp_l/2,y=clamp_y+feet_w-cable,z=cable,rz=angle)
s3d.material(jaw,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#888b8c39;)
jaws.append(jaw)
hinge=s3d.at(s3d.cylinder(&class="tok-comment">#39;clamp_hinge39;,d=border,h=foot*2),x=clamp_x-clamp_l/2+border,y=clamp_y+feet_w-cable,z=cable)
s3d.material(hinge,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#888b8c39;)
return s3d.group(&class="tok-comment">#39;welding_unit39;,body,feet,rim,twin,sockets,leads,torch,nozzle,holder,lever,plug,trigger,jaws,hinge)
def carrying_handle(w=140,d=73,h=16,arm=8,grip=23):
outline=s3d.poly([(-w/2,-d/2),(-w/2,d/6),s3d.arc(center=(-w/2+grip,d/6),r=grip,start=180,end=90),(w/2-grip,d/6+grip),s3d.arc(center=(w/2-grip,d/6),r=grip,start=90,end=0),(w/2,-d/2),(w/2-arm,-d/2),(w/2-arm,0),(w/2-grip, d/6),( -w/2+grip,d/6),(-w/2+arm,0),(-w/2+arm,-d/2)])
handle=s3d.extrude(&class="tok-comment">#39;handle39;,outline,h=h)
s3d.material(handle,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#25282b39;)
return s3d.group(&class="tok-comment">#39;carrying_handle39;,handle)
def rocker_button(w=16,d=17,h=26):
button=s3d.box(&class="tok-comment">#39;rocker39;,w=w,d=d,h=h)
s3d.material(button,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#ab242039;)
return s3d.group(&class="tok-comment">#39;rocker_button39;,button)
def current_switch(w=17,d=25,h=27):
knob=s3d.at(s3d.cylinder(&class="tok-comment">#39;dial39;,d=d,h=w),x=-w/2,z=h/2,ry=75.1)
s3d.material(knob,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#23272b39;)
return s3d.group(&class="tok-comment">#39;current_switch39;,knob)
def mode_switch(w=17,d=26,h=26):
knob=s3d.at(s3d.cylinder(&class="tok-comment">#39;dial39;,d=d,h=w),x=-w/2,z=h/2,ry=75.1)
s3d.material(knob,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#23272b39;)
return s3d.group(&class="tok-comment">#39;mode_switch39;,knob)