import sand3d as s3d
def triangle_ruler():
plate = s3d.at(frame_plate(), x=0.6, y=-17.5, z=0.1)
return s3d.assembly(class="tok-string">"triangle_ruler", plate)
def frame_plate(h=5.2, outer_a=(-101.6,97.5), outer_b=(102.1,173.5), outer_c=(6.4,-169.5), outer_d=(-1.6,-173.5), inner_a=(-63.6,80.5), inner_b=(-1.6,-86.5), inner_c=(55.4,124.5), corner=3):
plate = s3d.extrude(class="tok-string">"plate", s3d.poly([outer_a, outer_b, outer_c, outer_d]), h=h)
opening = s3d.extrude(class="tok-string">"opening", s3d.poly([inner_a, inner_b, inner_c], fillet=corner), h=h*3)
opening = s3d.at(opening, z=-h)
plate = s3d.cut(plate, opening)
s3d.material(plate, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#e6e6e6")
ridge = s3d.at(raised_ridge(), x=-34.6, y=-30.5, z=h-0.3)
return s3d.group(class="tok-string">"frame_plate", plate, ridge)
def raised_ridge(w=36, length=278, h=2.64, angle=20.1, end_trim=20):
profile = s3d.poly([(-w/2,0),(-w/2,h*0.75),s3d.spline([(-w/2,h*0.75),(-w*0.32,h), (0,h*0.22),(w*0.32,h),(w/2,h*0.85)]),(w/2,0)])
rail = s3d.extrude(class="tok-string">"ridge", profile, h=length)
rail = s3d.at(rail, rx=90, y=length/2)
clip = s3d.extrude(class="tok-string">"end_tapers", s3d.poly([(-w/2,-length/2),(w/2,-length/2+end_trim*3),(w/2,length/2),(-w/2,length/2-end_trim)]), h=h*2)
rail = s3d.intersect(rail, clip)
s3d.material(rail, class="tok-string">"plastic", color=class="tok-string">"class="tok-comment">#e6e6e6")
return s3d.at(s3d.group(class="tok-string">"raised_ridge", rail), rz=angle)