def create_hexapod(): # Some shortcuts L = lambda *args: cq.Location(cq.Vector(*args)) C = lambda *args: cq.Color(*args) # Leg assembly leg = MAssembly(upper_leg, name="upper", color=C("orange")).add(lower_leg, name="lower", color=C("orange"), loc=L(80, 0, 0)) # Hexapod assembly hexapod = (MAssembly( base, name="bottom", color=C("gray"), loc=L(0, 1.1 * width, 0)).add(base, name="top", color=C(0.9, 0.9, 0.9), loc=L(0, -2.2 * width, 0)).add(stand, name="front_stand", color=C(0.5, 0.8, 0.9), loc=L(40, 100, 0)).add(stand, name="back_stand", color=C(0.5, 0.8, 0.9), loc=L(-40, 100, 0))) for i, name in enumerate(leg_names): hexapod.add(leg, name=name, loc=L(100, -55 * (i - 1.7), 0)) return hexapod
def create_leg(x, y): L = lambda *args: cq.Location(cq.Vector(*args)) C = lambda *args: cq.Color(*args) leg = MAssembly(cq.Workplane("YZ").polyline([(0, 0), (x, 0), (x, y)]), name="base", color=C("Gray")) for i, name in enumerate(link_list): leg.add(parts[name], name=name, color=C(links[name]["col"]), loc=L(0, 0, i * 10 - 50)) return leg
def make_door(): door = ( MAssembly(name="door") # add a name for hierarchical addressing .add(w_slot, name="bottom") .add(h_slot, name="left", loc=L(0, 40, 0)) .add(h_slot, name="right", loc=L(0, 80, 0)) .add(w_slot, name="top", loc=L(0, 120, 0)) .add(conn, name="con_tl", color=cq.Color("black"), loc=L(0, 0, -40)) .add(conn, name="con_tr", color=cq.Color("black"), loc=L(0, 40, -40)) .add(conn, name="con_bl", color=cq.Color("black"), loc=L(0, 80, -40)) .add(conn, name="con_br", color=cq.Color("black"), loc=L(0, 120, -40)) .add( make_panel(W + 2 * SLOT_D, H + 2 * SLOT_D, PANEL_T, SLOT_D), name="panel", color=cq.Color(0, 0, 1, 0.2), loc=L(0, -40, H / 2), ) .add( make_handle(HANDLE_D, HANDLE_L, HANDLE_W), name="handle", color=cq.Color("yellow"), loc=L(0, -150, 0), ) ) return door
def create(): L = lambda *args: cq.Location(cq.Vector(*args)) C = lambda *args: cq.Color(*args) a = MAssembly(cyl3, name="cyl3", color=C(1, 0, 0), loc=L(-20, -10, 20)).add( box3, name="box3", color=C(1, 0, 0), loc=L(20, 10, 0) ) b = ( MAssembly(cyl2, name="cyl2", color=C(0, 0.5, 0.25), loc=L(0, -20, 20)) .add(box2, name="box2", color=C(0, 0.5, 0.25), loc=L(0, 20, 20)) .add(a, name="a") ) c = ( MAssembly(cyl1, name="cyl1", color=C(0, 0, 1), loc=L(10, 0, -10)) .add(box1, name="box1", color=C(0, 0, 1), loc=L(10, 0, 10)) .add(b, name="b") ) d = MAssembly(box0, name="box0", color=C(0.5, 0.5, 0.5), loc=L(30, 30, 30)).add(c, name="c") return d
def create_disk_arm(): L = lambda *args: cq.Location(cq.Vector(*args)) C = lambda name: web_color(name) return (MAssembly(base, name="base", color=C("silver"), loc=L(-dist_pivot / 2, 0, 0)).add(disk, name="disk", color=C("MediumAquaMarine"), loc=L(r_disk, -1.5 * r_disk, 0)).add(arm, name="arm", color=C("orange"), loc=L(0, 10 * nr, 0)))
def create_bearing(): L = lambda *args: cq.Location(cq.Vector(*args)) C = lambda *args: cq.Color(*args) assy = MAssembly(outer, loc=L(0, 0, ball_diam / 2), name="outer", color=C("orange")) assy.add(inner, loc=L(20, 0, 0), name="inner", color=C("orange")) for i in range(number_balls): assy.add(ball, loc=L(6 * i, 20, 0), name=balls[i], color=C("black")) return assy