import sand3d as s3d
def trolley():
base = s3d.at(rail_frame(), z=229)
a = s3d.at(caster_fork(), x=335.5, y=-513, z=72)
b = s3d.at(caster_fork(wheel_joint=&class="tok-comment">#39;joint_sm_wheel1_a01_joint_0039;, flip=True), x=-335.5, y=-513, z=72)
c = s3d.at(swivel_fork(), x=335.5, y=513, z=72)
d = s3d.at(swivel_fork(wheel_joint=&class="tok-comment">#39;joint_sm_wheel4_a01_joint_0039;, flip=True), x=-335.5, y=513, z=72)
s3d.joint(&class="tok-comment">#39;joint_sm_wheelbase2_a01_joint_00class="tok-string">39;, a, s3d.local(base, x=342, y=-513, z=4), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_sm_wheelbase1_a01_joint_00class="tok-string">39;, b, s3d.local(base, x=-342, y=-513, z=4), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_sm_wheelbase3_a01_joint_00class="tok-string">39;, c, s3d.local(base, x=342, y=513, z=4), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
s3d.joint(&class="tok-comment">#39;joint_sm_wheelbase4_a01_joint_00class="tok-string">39;, d, s3d.local(base, x=-342, y=513, z=4), kind=39;continuousclass="tok-string">39;, axis=39;+Z39;)
return s3d.assembly(&class="tok-comment">#39;trolley39;, base, a, b, c, d)
def rail_frame(w=821, d=1198, h=254, rail=45, t=7, low=12, rise=121, inset=290, channel=39, ct=3, post=38, ear_w=94, ear_h=71, ear_t=7, ear_hole=39):
solids=[]
for z in (low, low+rise):
top = z > low
p = s3d.poly(pts=[(0,0),(rail,0),(rail,t),(t,t),(t,rail),(0,rail)])
if top:
p = s3d.poly(pts=[(0,0),(t,0),(t,rail-t),(rail,rail-t),(rail,rail),(0,rail)])
long = s3d.at(s3d.extrude(&class="tok-comment">#39;long_angle39;, p, h=d), x=-w/2, y=d/2, z=z, rx=90)
solids.extend([long,s3d.transform(s3d.copy(long),mirror=&class="tok-comment">#39;x39;)])
end = s3d.at(s3d.extrude(&class="tok-comment">#39;end_angle39;, p, h=w-2*t), x=-w/2+t, y=-d/2, z=z, rx=90, rz=90)
solids.extend([end,s3d.transform(s3d.copy(end),mirror=&class="tok-comment">#39;y39;)])
for x in (-w/2+post/2,w/2-post/2):
for y in (-d/2+post/2,d/2-post/2):
upright=s3d.box(&class="tok-comment">#39;upright39;, w=post,d=post,h=rise+rail)
upright=s3d.shell(upright,t=t,open=&class="tok-comment">#39;top bottom39;)
solids.append(s3d.at(upright,x=x,y=y,z=low))
p=s3d.poly(pts=[(-channel/2,0),(channel/2,0),(channel/2,ct),(-channel/2+ct,ct),(-channel/2+ct,channel-ct),(channel/2,channel-ct),(channel/2,channel),(-channel/2,channel)])
inner=s3d.at(s3d.extrude(&class="tok-comment">#39;inset_channel39;,p,h=d),x=-inset,y=d/2,z=low,rx=90)
solids.extend([inner,s3d.transform(s3d.copy(inner),mirror=&class="tok-comment">#39;x39;)])
for x in (-1,1):
for y in (-1,1):
plate=s3d.extrude(&class="tok-comment">#39;mount_plate39;,s3d.rect(w=128,d=128,r=t),h=t)
solids.append(s3d.at(plate,x=x*342,y=y*513,z=0))
ear=s3d.extrude(&class="tok-comment">#39;lifting_ear39;,s3d.rect(w=ear_w,d=ear_h,r=t),h=ear_t)
ear=s3d.hole(ear,d=ear_hole,on=(0,ear_h/8))
solids.append(s3d.at(ear,x=x*(w/2-ear_w/2+t),y=y*(d/2+t),z=h-ear_h/2,rx=90))
ear2=s3d.extrude(&class="tok-comment">#39;lifting_ear39;,s3d.rect(w=ear_w,d=ear_h,r=t),h=ear_t)
ear2=s3d.hole(ear2,d=ear_hole,on=(0,ear_h/8))
solids.append(s3d.at(ear2,x=x*(w/2+t),y=y*(d/2-ear_w/2+t),z=h-ear_h/2,rx=90,rz=90))
s3d.material(solids,kind=&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#85898b39;)
return s3d.group(&class="tok-comment">#39;rail_frame39;,solids)
def caster_fork(w=105,d=93,h=161,head=92,head_h=47,cheek=12,offset=37,axle_z=16,wheel_joint=&class="tok-comment">#39;joint_sm_wheel2_a01_joint_0039;,flip=False):
headpart=s3d.at(s3d.tube(&class="tok-comment">#39;swivel39;,d=head,d_in=head-head_h/2,h=head_h),x=w/2-head/2,z=h-head_h)
p=s3d.poly(pts=[(-w/2,axle_z),(-w/2+cheek,0),(-w/2+cheek*2,0),(w/2,h-head_h),(w/2,h-head_h+cheek),(-w/2,h-head_h+cheek)])
side=s3d.at(s3d.extrude(&class="tok-comment">#39;fork_cheek39;,p,h=cheek),y=d/2,z=0,rx=90)
other=s3d.transform(s3d.copy(side),mirror=&class="tok-comment">#39;y39;)
axle=s3d.at(s3d.cylinder(&class="tok-comment">#39;axle39;,d=30,h=d),x=-offset,y=d/2,z=axle_z,rx=90)
solids=[headpart,side,other,axle]
s3d.material(solids,kind=&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#969b9e39;)
host=s3d.group(&class="tok-comment">#39;fork_metal39;,solids)
wheel=s3d.at(caster_wheel(),x=-offset,z=-72)
s3d.joint(wheel_joint,wheel,s3d.local(host,x=-37,y=0,z=16),kind=&class="tok-comment">#39;revoluteclass="tok-string">39;,axis=39;+Y39;,range=(-62831.9,62831.9))
result=s3d.group(&class="tok-comment">#39;fork_body39;,host,wheel)
if flip:
result=s3d.transform(result,mirror=&class="tok-comment">#39;x39;)
return s3d.group(&class="tok-comment">#39;caster_fork39;,result)
def caster_wheel(w=175,d=52,h=175,rim=10,web=16,hub=61):
tire=s3d.tube(&class="tok-comment">#39;tire39;,d=w,d_in=w-2*rim,h=d-6)
tire=s3d.fillet(tire,r=5)
webpart=s3d.at(s3d.cylinder(&class="tok-comment">#39;wheel_web39;,d=w-rim,h=web),z=(d-6-web)/2)
hubpart=s3d.at(s3d.cylinder(&class="tok-comment">#39;hub39;,d=hub,h=d),z=-3)
s3d.material(tire,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#36393b39;)
s3d.material([webpart,hubpart],kind=&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#767b7d39;)
wheel=s3d.group(&class="tok-comment">#39;caster_wheel39;,tire,webpart,hubpart)
return s3d.group(&class="tok-comment">#39;wheel39;,s3d.at(wheel,y=(d-6)/2,z=h/2,rx=90))
def swivel_fork(w=105,d=92,h=161,wheel_joint=&class="tok-comment">#39;joint_sm_wheel3_a01_joint_0039;,flip=False):
return s3d.group(&class="tok-comment">#39;swivel_fork39;,caster_fork(w=w,d=d,h=h,wheel_joint=wheel_joint,flip=flip))
def swivel_wheel(w=175,d=52,h=175):
return s3d.group(&class="tok-comment">#39;swivel_wheel39;,caster_wheel(w=w,d=d,h=h))