import sand3d as s3d
def office_chair():
base = s3d.at(pedestal(), y=-29.5, z=57)
f = s3d.at(front_caster(), y=-319.5, z=16)
a = s3d.at(lateral_caster(), x=291, y=-108, z=16)
b = s3d.transform(s3d.at(lateral_caster(index=&class="tok-comment">#39;5class="tok-string">39;), x=291, y=-108, z=16), mirror=39;x39;)
c = s3d.at(rear_caster(), x=180, y=234, z=16)
e = s3d.transform(s3d.at(rear_caster(index=&class="tok-comment">#39;4class="tok-string">39;), x=180, y=234, z=16), mirror=39;x39;)
seat = s3d.at(upholstered_seat(), y=39.5, z=156)
for ob, index, x, y in [(f,&class="tok-comment">#39;1class="tok-string">39;,0,-277),(a,39;2class="tok-string">39;,291,-65),(b,39;5class="tok-string">39;,-291,-65),(c,39;3class="tok-string">39;,180,277),(e,39;439;,-180,277)]:
s3d.joint(&class="tok-comment">#39;joint_sm_wheelclass="tok-string">39;+index+39;_a01_joint_00class="tok-string">39;, ob, s3d.local(base,x=x,y=y,z=0), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_sm_seat_a01_joint_00class="tok-string">39;,seat,s3d.local(base,x=0,y=29.5,z=303),kind=39;continuousclass="tok-string">39;,axis=39;+Z39;)
return s3d.assembly(&class="tok-comment">#39;office_chair39;,base,f,a,b,c,e,seat)
def pedestal(radius=323, hub=96, lower=79, middle=71, upper=64, h=303, spoke_w=62, tip_w=34, tip_h=33, root_h=66):
core = s3d.at(s3d.cylinder(&class="tok-comment">#39;hub39;,d=hub,h=root_h),y=29.5)
foot = s3d.loft(&class="tok-comment">#39;spoke39;,s3d.station(z=0,w=spoke_w,d=root_h,n=4),s3d.station(z=radius,w=tip_w,d=tip_h,y=-root_h/4,n=4))
s3d.fillet(foot,r=tip_h/3,edges=&class="tok-comment">#39;end39;)
channel=s3d.loft(&class="tok-comment">#39;underside_channel39;,s3d.station(z=-1,w=spoke_w-10,d=root_h,y=-root_h/2-1,n=4),s3d.station(z=radius-tip_w,w=tip_w-10,d=tip_h,y=-root_h/4-tip_h/2-1,n=4))
s3d.cut(foot,channel)
foot = s3d.at(foot,rx=90)
feet = s3d.at(foot,on=s3d.ring(n=5,r=0,on=s3d.local(core)),y=0,z=root_h/2)
s3d.join(core,feet)
shaft = s3d.at(s3d.cylinder(&class="tok-comment">#39;column39;,d=lower,h=173),y=29.5,z=root_h/2)
mid = s3d.at(s3d.cylinder(&class="tok-comment">#39;sleeve39;,d=middle,h=72),y=29.5,z=193)
top = s3d.at(s3d.cylinder(&class="tok-comment">#39;upper39;,d=upper,h=h-253),y=29.5,z=253)
s3d.join(core,shaft,mid,top)
s3d.hole(core,d=32,on=core.face(&class="tok-comment">#39;top39;))
s3d.material(core,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#30323639;)
return s3d.group(&class="tok-comment">#39;pedestal39;,core)
def front_caster(w=33,d=59,h=41):
solid = caster_shell(w=w,d=d,h=h)
tire = s3d.at(front_tire(),y=-3,z=-18)
s3d.joint(&class="tok-comment">#39;joint_sm_tire1_a01_joint_00class="tok-string">39;,tire,s3d.local(solid,x=0,y=-3,z=9),kind=39;continuousclass="tok-string">39;,axis=39;+X39;)
return s3d.group(&class="tok-comment">#39;front_caster39;,solid,tire)
def caster_shell(w,d,h):
boss = s3d.cylinder(&class="tok-comment">#39;swivel39;,d=w,h=h)
s3d.fillet(boss,r=w/3,edges=&class="tok-comment">#39;bottom39;)
boss = s3d.at(boss,y=d/2-w/2)
arch = s3d.tube(&class="tok-comment">#39;mudguard39;,d=d,d_in=d-4,h=w)
arch = s3d.at(arch,ry=90,x=-w/2,y=-3,z=h-d/2)
tool = s3d.at(s3d.box(&class="tok-comment">#39;trim39;,w=w*2,d=d*2,h=d),z=-d)
s3d.cut(arch,tool)
s3d.join(boss,arch)
s3d.material(boss,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#24262939;)
return boss
def front_tire(w=40,d=50):
return s3d.group(&class="tok-comment">#39;front_tire39;,wheel_solid(w=w,d=d))
def wheel_solid(w,d):
ob = s3d.cylinder(&class="tok-comment">#39;rubber_wheel39;,d=d,h=w)
s3d.fillet(ob,r=d/12)
ob = s3d.at(ob,ry=90,x=-w/2,z=d/2)
s3d.material(ob,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#17191b39;)
return ob
def lateral_caster(w=34,d=60,h=41,index=&class="tok-comment">#39;239;):
solid = caster_shell(w=w,d=d,h=h)
tire = s3d.at(lateral_tire(),y=-3.5,z=-18)
s3d.joint(&class="tok-comment">#39;joint_sm_tireclass="tok-string">39;+index+39;_a01_joint_00class="tok-string">39;,tire,s3d.local(solid,x=0,y=-3,z=9),kind=39;continuousclass="tok-string">39;,axis=39;+X39;)
return s3d.group(&class="tok-comment">#39;lateral_caster39;,solid,tire)
def lateral_tire(w=40,d=50):
return s3d.group(&class="tok-comment">#39;lateral_tire39;,wheel_solid(w=w,d=d))
def rear_caster(w=34,d=60,h=41,index=&class="tok-comment">#39;339;):
solid = caster_shell(w=w,d=d,h=h)
tire = s3d.at(rear_tire(),y=-2.5,z=-18)
s3d.joint(&class="tok-comment">#39;joint_sm_tireclass="tok-string">39;+index+39;_a01_joint_00class="tok-string">39;,tire,s3d.local(solid,x=0,y=-3,z=9),kind=39;continuousclass="tok-string">39;,axis=39;+X39;)
return s3d.group(&class="tok-comment">#39;rear_caster39;,solid,tire)
def rear_tire(w=40,d=50):
return s3d.group(&class="tok-comment">#39;rear_tire39;,wheel_solid(w=w,d=d))
def upholstered_seat(sw=538,bw=518,bd=105,arm_x=278,arm_w=53,arm_t=15):
front=-316
roll=-240
middle=-170
rear=204
floor=275
sitting=350
crest=394
lip=front+16
cushion = s3d.body(&class="tok-comment">#39;seat_cushion39;,plan=[(front,200),(lip,388),(roll,sw-30),(middle,sw),(rear,sw-30)],top=[(front,321),(lip,369),(roll,crest),(middle,crest-10),(0,sitting),(rear,sitting)],bottom=[(front,320),(lip,283),(roll,floor),(rear,floor)],n=4)
edge = s3d.body(&class="tok-comment">#39;side_roll39;,plan=[(roll,bd/2),(middle,bd),(rear,bd/2)],top=[(roll,crest),(middle,crest),(rear,sitting+25)],bottom=floor,n=2)
edge = s3d.at(edge,x=sw/2-bd/1.5)
s3d.join(cushion,edge,s3d.transform(s3d.copy(edge),mirror=&class="tok-comment">#39;x39;))
sections=[(330,205,75,190),(456,194,81,180),(711,246,62,225),(875,263,bd,270),(905,273,80,273),(930,273,12,273)]
back = s3d.loft(&class="tok-comment">#39;back39;,*[s3d.station(z=z,w=bw if z<905 else bw-60,d=depth,y=y,n=8) for z,y,depth,side_y in sections])
bolster = s3d.loft(&class="tok-comment">#39;bolster39;,*[s3d.station(z=z,w=bd if z<875 else bd/2,d=bd if z<875 else depth,y=side_y,x=bw/2-bd/2,n=2) for z,y,depth,side_y in sections])
s3d.join(back,bolster,s3d.transform(s3d.copy(bolster),mirror=&class="tok-comment">#39;x39;))
arm_path = s3d.spline([(arm_x,170,310),(arm_x,-174,310),(arm_x,-169,400),(arm_x,-115,500),(arm_x,0,520),(arm_x,183,520)])
arm = s3d.sweep(&class="tok-comment">#39;arm_loop39;,s3d.rect(w=arm_w,d=arm_t,r=arm_t/3),path=arm_path)
image = s3d.transform(s3d.copy(arm),mirror=&class="tok-comment">#39;x39;)
mechanism = s3d.at(s3d.box(&class="tok-comment">#39;mechanism39;,w=110,d=180,h=35),y=-59.5,z=230)
plate=s3d.at(s3d.extrude(&class="tok-comment">#39;seat_plate39;,s3d.rect(w=486,d=463,r=20),h=14),y=-49.5,z=264)
knob=s3d.at(s3d.cylinder(&class="tok-comment">#39;tilt_knob39;,d=40,h=72),y=-140,z=175,rx=-15)
rod = s3d.at(s3d.cylinder(&class="tok-comment">#39;piston39;,d=16,h=188),y=-63.5,z=16)
lever = s3d.at(adjustment_lever(),x=-171.5,y=6.5,z=198)
body = s3d.group(&class="tok-comment">#39;upholstered_seat39;,cushion,back,arm,image,mechanism,plate,knob,rod)
s3d.material(cushion,&class="tok-comment">#39;leatherclass="tok-string">39;,color=39;#292a2d39;)
s3d.material(back,&class="tok-comment">#39;leatherclass="tok-string">39;,color=39;#292a2d39;)
for ob in [arm,image,mechanism,plate,knob]:
s3d.material(ob,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#27292b39;)
s3d.material(rod,&class="tok-comment">#39;chrome39;)
s3d.joint(&class="tok-comment">#39;joint_sm_seat_lock_a01_joint_00class="tok-string">39;,lever,s3d.local(body,x=-49,y=-25.5,z=254),kind=39;revoluteclass="tok-string">39;,axis=39;+Y39;,range=(-6.1,7.8))
return s3d.group(&class="tok-comment">#39;seat39;,body,lever)
def adjustment_lever(w=257,d=70,h=59):
rod = s3d.wire(&class="tok-comment">#39;lever39;,path=[(w/2, -d/2,h),( -w/2+20,-d/2,h),(-w/2, d/2,8)],d=6)
grip = s3d.at(s3d.box(&class="tok-comment">#39;grip39;,w=30,d=35,h=12),x=-w/2+10,y=d/2-10)
s3d.fillet(grip,r=5)
s3d.material(rod,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#41424739;)
s3d.material(grip,&class="tok-comment">#39;plasticclass="tok-string">39;,color=39;#22232639;)
return s3d.group(&class="tok-comment">#39;adjustment_lever39;,rod,grip)