import sand3d as s3d
def expanding_barrier():
root = s3d.at(barrier_frame(), x=-31, y=-33, z=122)
end = s3d.at(end_caster(number=1),x=-224,y=-3034.5,z=36)
end_image = s3d.at(end_caster(number=2),x=161,y=-3034.5,z=36)
middle = s3d.at(middle_caster(number=3),x=-224,y=-41,z=42)
middle_image = s3d.at(middle_caster(number=4),x=161,y=-41,z=42)
far = s3d.at(far_caster(number=5),x=-224,y=2934.5,z=36)
far_image = s3d.at(far_caster(number=6),x=161,y=2934.5,z=36)
for child,num,x,y in [(end,1,-193,-2985),(end_image,2,192,-2985),(middle,3,-193,0),(middle_image,4,192,0),(far,5,-193,2985),(far_image,6,192,2985)]:
s3d.joint(&class="tok-comment">#39;joint_sm_wheel%d_a02_joint_00class="tok-string">39; % num,child,on=s3d.local(root,x=x,y=y,z=1),kind=39;revoluteclass="tok-string">39;,axis=39;+Z39;,range=(-3.1,3.1))
return s3d.assembly(&class="tok-comment">#39;expanding_barrier39;,root,end,end_image,middle,middle_image,far,far_image)
def barrier_frame(w=486.6,h=1540,post=42,foot_d=70,foot_h=42,pitch=366,rise=1200,run=1110,strip=22,thick=7,low=178,bay=2984.5,angle=42.7688):
solids=[]
for y in [-bay,0,bay]:
foot=s3d.at(s3d.box(&class="tok-comment">#39;foot39;,w=w,d=foot_d,h=foot_h),y=y,z=8)
upright=s3d.at(s3d.cylinder(&class="tok-comment">#39;post39;,d=post,h=h-foot_h),y=y,z=foot_h-1)
solids.extend([foot,upright])
for level in [370,770,1170]:
collar=s3d.at(s3d.tube(&class="tok-comment">#39;collar39;,d=post+10,d_in=post-2,h=40),y=y,z=level)
solids.append(collar)
for center in [-bay/2,bay/2]:
for direction in [-1,1]:
for i in range(-3,9):
start=center-bay/2+198+i*pitch
t0=max(0,min((center-bay/2-start)/(direction*run),(center+bay/2-start)/(direction*run)))
t1=min(1,max((center-bay/2-start)/(direction*run),(center+bay/2-start)/(direction*run)))
if t1<=t0:
continue
rod=s3d.box(&class="tok-comment">#39;lattice_strip39;,w=thick,d=strip,h=(run*run+rise*rise)**0.5*(t1-t0))
rod=s3d.at(rod,x=direction*thick/2,y=start+direction*run*t0,z=low+rise*t0,rx=-direction*angle)
solids.append(rod)
for ob in solids:
s3d.material(ob,kind=&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#92989539;)
return s3d.group(&class="tok-comment">#39;barrier_frame39;,solids)
def end_caster(w=56,d=85,h=91,number=1):
solid=caster_bracket(w=w,d=d,h=h)
tire=s3d.at(end_tire(),x=-0.5,y=-5,z=-36)
part=s3d.group(&class="tok-comment">#39;end_caster39;,solid,tire)
s3d.joint(&class="tok-comment">#39;joint_sm_tire%d_a02_joint_00class="tok-string">39; % number,tire,on=s3d.local(part,x=0,y=-5,z=15),kind=39;continuousclass="tok-string">39;,axis=39;+X39;)
return part
def caster_bracket(w=56,d=85,h=91,t=6):
cap=s3d.at(s3d.cylinder(&class="tok-comment">#39;swivel39;,d=w,h=t*2),z=h-t*2)
cheeks=[]
for x in [-(w-t)/2,(w-t)/2]:
cheek=s3d.at(s3d.box(&class="tok-comment">#39;fork39;,w=t,d=d/2,h=h-t),x=x,y=-d/8)
cheeks.append(cheek)
solid=s3d.join(cap,cheeks)
s3d.material(solid,kind=&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#8b918e39;)
return solid
def end_tire(w=25,d=103):
solid=s3d.at(s3d.cylinder(&class="tok-comment">#39;tire39;,d=d,h=w),x=-w/2,z=d/2,ry=90)
s3d.material(solid,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#36393639;)
return s3d.group(&class="tok-comment">#39;end_tire39;,solid)
def middle_caster(w=46,d=46,h=84,number=3):
solid=caster_bracket(w=w,d=d,h=h)
tire=s3d.at(middle_tire(),y=-13.5,z=-42)
part=s3d.group(&class="tok-comment">#39;middle_caster39;,solid,tire)
s3d.joint(&class="tok-comment">#39;joint_sm_tire%d_a02_joint_00class="tok-string">39; % number,tire,on=s3d.local(part,x=0,y=-14,z=9),kind=39;continuousclass="tok-string">39;,axis=39;+X39;)
return part
def middle_tire(w=24,d=103):
solid=s3d.at(s3d.cylinder(&class="tok-comment">#39;tire39;,d=d,h=w),x=-w/2,z=d/2,ry=90)
s3d.material(solid,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#36393639;)
return s3d.group(&class="tok-comment">#39;middle_tire39;,solid)
def far_caster(w=56,d=85,h=91,number=5):
solid=caster_bracket(w=w,d=d,h=h)
tire=s3d.at(far_tire(),x=-0.5,y=-4.5,z=-36)
part=s3d.group(&class="tok-comment">#39;far_caster39;,solid,tire)
s3d.joint(&class="tok-comment">#39;joint_sm_tire%d_a02_joint_00class="tok-string">39; % number,tire,on=s3d.local(part,x=0,y=-4.5,z=15),kind=39;continuousclass="tok-string">39;,axis=39;+X39;)
return part
def far_tire(w=25,d=104):
solid=s3d.at(s3d.cylinder(&class="tok-comment">#39;tire39;,d=d,h=w),x=-w/2,z=d/2,ry=90)
s3d.material(solid,kind=&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#36393639;)
return s3d.group(&class="tok-comment">#39;far_tire39;,solid)