import sand3d as s3d
def caster_platform():
base = s3d.at(platform(), x=11, y=-9, z=78)
bars = []
for x, name, limits in [(-140, &class="tok-comment">#39;joint_lhandler_01_joint_00class="tok-string">39;, (0,180)), (162, 39;joint_rhandler_01_joint_0039;, (-180,0))]:
bar = s3d.at(side_bar(), x=x, y=-9, z=69)
s3d.joint(name, bar, on=s3d.local(base, x=x-11, y=163, z=42), axis=&class="tok-comment">#39;+Y39;, range=limits)
bars.append(bar)
casters = []
for x, y, front, swivel_name, wheel_name, brake_name in [(-106,157.5,True,&class="tok-comment">#39;joint_lfswivel_01_joint_00class="tok-string">39;,39;joint_lfwheel_01_joint_00class="tok-string">39;,39;joint_lfbrake_01_joint_00class="tok-string">39;),(128,157.5,True,39;joint_rfswivel_01_joint_00class="tok-string">39;,39;joint_rfwheel_01_joint_00class="tok-string">39;,39;joint_rfbrake_01_joint_00class="tok-string">39;),(-106,-163,False,39;joint_lrwivel_01_joint_00class="tok-string">39;,39;joint_lbwheel_01_joint_00class="tok-string">39;,39;joint_lbbrake_01_joint_00class="tok-string">39;),(128,-163,False,39;joint_rrswivel_01_joint_00class="tok-string">39;,39;joint_rbwheel_01_joint_00class="tok-string">39;,39;joint_rbbrake_01_joint_0039;)]:
caster = forward_swivel(wheel_name=wheel_name, brake_name=brake_name) if front else rear_swivel(wheel_name=wheel_name, brake_name=brake_name)
caster = s3d.at(caster, x=x, y=y, z=31)
s3d.joint(swivel_name, caster, on=s3d.local(base, x=x-11, y=160 if front else -160, z=18), kind=&class="tok-comment">#39;continuousclass="tok-string">39;, axis=39;+Z39;)
casters.append(caster)
return s3d.assembly(&class="tok-comment">#39;caster_platform39;, base, bars, casters)
def platform(w=313,d=380,t=5,span=290,rise=39,bolt_d=19,bolt_h=14):
path=s3d.spline([(-d/2,rise),(-115,rise),(-85,24),(-50,3),(-35,0),(35,0),(50,3),(85,24),(115,rise),(d/2,rise)],tangents=((1,0),(1,0)))
sheet=s3d.extrude(&class="tok-comment">#39;bent_sheet39;,s3d.stroke(path,t=t),h=w)
sheet=s3d.at(sheet,x=-w/2,rx=90,rz=90,z=t/2)
outline=s3d.poly([(-w/2,-d/2),(w/2,-d/2),(w/2,-115),(span/2,-95),(span/2,95),(w/2,115),(w/2,d/2),(-w/2,d/2),(-w/2,115),(-span/2,95),(-span/2,-95),(-w/2,-115)],fillet=20)
trim=s3d.extrude(&class="tok-comment">#39;rounded_perimeter39;,outline,h=rise+t*2)
sheet=s3d.intersect(sheet,trim)
s3d.material(sheet,&class="tok-comment">#39;brushed_steelclass="tok-string">39;,color=39;#92989c39;)
bolts=[]
for x in [-117,117]:
for y in [-160,160]:
bolt=s3d.at(s3d.cylinder(&class="tok-comment">#39;corner_bolt39;,d=bolt_d,h=bolt_h),x=x,y=y,z=rise+t)
s3d.material(bolt,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#858b9039;)
bolts.append(bolt)
return s3d.group(&class="tok-comment">#39;platform39;,sheet,bolts)
def side_bar(d=312,h=54,wire_d=5,grip_l=160,pivot_d=7):
grip=s3d.at(s3d.cylinder(&class="tok-comment">#39;handle_grip39;,d=wire_d,h=grip_l),y=-grip_l/2,z=wire_d/2,rx=-90)
pivots=[]
for y in [-d/2,d/2]:
pivot=s3d.at(s3d.cylinder(&class="tok-comment">#39;handle_pivot39;,d=pivot_d,h=wire_d),x=-wire_d/2,y=y,z=h-wire_d/2,ry=90)
s3d.material(pivot,&class="tok-comment">#39;chromeclass="tok-string">39;,color=39;#969da139;)
pivots.append(pivot)
s3d.material(grip,&class="tok-comment">#39;chromeclass="tok-string">39;,color=39;#969da139;)
return s3d.group(&class="tok-comment">#39;side_bar39;,grip,pivots)
def forward_swivel(w=54,d=65,h=78,t=5,collar_d=49,collar_h=17,wheel_name=&class="tok-comment">#39;joint_lfwheel_01_joint_00class="tok-string">39;,brake_name=39;joint_lfbrake_01_joint_0039;):
solid=fork_solid(w=w,d=d,h=h,t=t,collar_d=collar_d,collar_h=collar_h)
wheel=s3d.at(forward_wheel(),y=23,z=-33)
brake=s3d.at(forward_brake(),y=46,z=7)
parent=s3d.group(&class="tok-comment">#39;forward_swivel39;,solid)
s3d.joint(wheel_name,wheel,on=s3d.local(parent,x=0,y=23,z=10),kind=&class="tok-comment">#39;continuousclass="tok-string">39;,axis=39;-X39;)
s3d.joint(brake_name,brake,on=s3d.local(parent,x=0,y=23,z=54),axis=&class="tok-comment">#39;-X39;,range=(0,4.5))
return s3d.group(&class="tok-comment">#39;forward_swivel_group39;,parent,wheel,brake)
def fork_solid(w,d,h,t,collar_d,collar_h):
collar=s3d.at(s3d.cone(&class="tok-comment">#39;swivel_collar39;,d=collar_d,h=collar_h,d2=collar_d-t),y=-d/10,z=h-collar_h)
collar=s3d.hole(collar,d=t*3,on=collar.face(&class="tok-comment">#39;top39;))
ring=s3d.at(s3d.cylinder(&class="tok-comment">#39;bearing_rim39;,d=w,h=t),y=-d/10,z=h-collar_h-t/2)
fork=s3d.body(&class="tok-comment">#39;pressed_fork39;,plan=[(-d/2,w-t*3),(-d/10,w),(d/4,w-t*2),(d/2,w-t*3)],top=h-collar_h,bottom=[(-d/2,t*8),(-d/10,t*5),(d/4,0),(d/2,0)],n=20)
cavity=s3d.body(&class="tok-comment">#39;fork_opening39;,plan=[(-d/2-t,w-t*4),(-d/10,w-t),(d/4,w-t*3),(d/2+t,w-t*4)],top=h-collar_h-t,bottom=-t,n=20)
fork=s3d.cut(fork,cavity)
axle=s3d.at(s3d.cylinder(&class="tok-comment">#39;axle39;,d=t*2,h=w),x=-w/2,y=23,z=10,ry=90)
nut=s3d.at(s3d.cylinder(&class="tok-comment">#39;axle_nut39;,d=t*3,h=t),x=-w/2,y=23,z=10,ry=90)
twin=s3d.transform(s3d.copy(nut),mirror=&class="tok-comment">#39;x39;)
solid=s3d.join(collar,ring,fork,axle,nut,twin)
s3d.material(solid,&class="tok-comment">#39;brushed_steelclass="tok-string">39;,color=39;#92999f39;)
return solid
def forward_wheel(w=30,d=82,edge=4,hub_d=32,recess_d=59,recess=8):
tire=s3d.cylinder(&class="tok-comment">#39;wheel39;,d=d,h=w)
tire=s3d.fillet(tire,r=edge,edges=&class="tok-comment">#39;all39;)
tire=s3d.pocket(tire,s3d.circle(d=recess_d),depth=recess,on=tire.face(&class="tok-comment">#39;top39;))
tire=s3d.pocket(tire,s3d.circle(d=recess_d),depth=recess,on=tire.face(&class="tok-comment">#39;bottom39;))
tire=s3d.at(tire,x=-w/2,z=d/2,ry=90)
s3d.material(tire,&class="tok-comment">#39;rubberclass="tok-string">39;,color=39;#33383b39;)
hubs=s3d.at(s3d.cylinder(&class="tok-comment">#39;hub39;,d=hub_d,h=w+2),x=-w/2-1,z=d/2,ry=90)
s3d.material(hubs,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#8e959b39;)
return s3d.group(&class="tok-comment">#39;forward_wheel39;,tire,hubs)
def forward_brake(w=36,d=49,h=50,t=3,arm_top=-7,arm_end=10):
bottom=s3d.at(s3d.cylinder(&class="tok-comment">#39;brake_crossbar39;,d=t,h=w),x=-w/2,y=d/2-t/2,z=t/2,ry=90)
arm=s3d.wire(&class="tok-comment">#39;brake_arm39;,path=[(-w/2+t/2,arm_top,h-t),(-w/2+t/2,arm_end,t*4)],d=t)
other=s3d.transform(s3d.copy(arm),mirror=&class="tok-comment">#39;x39;)
s3d.material(bottom,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#7e878e39;)
s3d.material(arm,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#7e878e39;)
s3d.material(other,&class="tok-comment">#39;steelclass="tok-string">39;,color=39;#7e878e39;)
return s3d.group(&class="tok-comment">#39;forward_brake39;,bottom,arm,other)
def rear_swivel(w=54,d=64,h=78,t=5,collar_d=49,collar_h=17,wheel_name=&class="tok-comment">#39;joint_lbwheel_01_joint_00class="tok-string">39;,brake_name=39;joint_lbbrake_01_joint_0039;):
solid=fork_solid(w=w,d=d,h=h,t=t,collar_d=collar_d,collar_h=collar_h)
wheel=s3d.at(rear_wheel(),y=22.5,z=-33)
brake=s3d.at(rear_brake(),y=45,z=7)
parent=s3d.group(&class="tok-comment">#39;rear_swivel39;,solid)
s3d.joint(wheel_name,wheel,on=s3d.local(parent,x=0,y=23,z=10),kind=&class="tok-comment">#39;continuousclass="tok-string">39;,axis=39;-X39;)
s3d.joint(brake_name,brake,on=s3d.local(parent,x=0,y=22,z=54),axis=&class="tok-comment">#39;-X39;,range=(0,4.5))
return s3d.group(&class="tok-comment">#39;rear_swivel_group39;,parent,wheel,brake)
def rear_wheel(w=30,d=82,edge=4,hub_d=32):
return s3d.group(&class="tok-comment">#39;rear_wheel39;,forward_wheel(w=w,d=d,edge=edge,hub_d=hub_d))
def rear_brake(w=36,d=50,h=48,t=3):
return s3d.group(&class="tok-comment">#39;rear_brake39;,forward_brake(w=w,d=d,h=h,t=t))