Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from openscad import *
- from collections import namedtuple
- from collections import OrderedDict
- Button=namedtuple('Button', ['body', 'label'])
- width = 10.8;
- height = 6.9;
- depth = 4.8;
- stopper_extra_width = -1.9;
- stopper_extra_height = 1;
- stopper_depth = 2.4;
- text_size = 2.8;
- text_depth = 0.4;
- distance = 5;
- def button(caption):
- label=text(
- caption, halign="center", valign="center",
- size=text_size, font="Arial:style=Black"
- ).linear_extrude(text_depth)
- stopper=union(
- square(
- [width+stopper_extra_width,
- height+stopper_extra_height],
- center=True
- ),
- square([width,height], center=True)
- ).linear_extrude(stopper_depth)
- body=square([width, height], center=True)\
- .linear_extrude(height)
- all = union(stopper, body.up(stopper_depth))
- all = all - label.up(stopper_depth+height-text_depth)
- return Button(
- body=all,
- label=label.up(stopper_depth+height-text_depth),
- )
- all = [
- ["D", "MNU"],
- ["FPL", "PRC"],
- ["CLR", "ENT"],
- ["AP", "FD"],
- ["HDG", "ALT"],
- ["NAV", "VNV"],
- ["APR", "BC"],
- ["VS", "UP"],
- ["FLC", "DN"]
- ]
- bodies=[]
- labels=[]
- for i, row in enumerate(all):
- for j, col in enumerate(row):
- b=button(col)
- def displace(o):
- return o.front(i*(width+distance))\
- .right(j*(width+distance))
- bodies.append(displace(b.body.color("black")))
- labels.append(displace(b.label.color("white")))
- exports={}
- for i, body in enumerate(bodies):
- exports["body_%s" % i]=body
- for i, label in enumerate(labels):
- exports["label_%s" % i]=label
- show(union(*exports.values()))
- export(exports,"buttons.3mf")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement