# add mates to the connectors for c in ["con_tl", "con_tr", "con_br", "con_bl"]: door.mate(f"{c}?X", name=f"{c}_0", transforms=odict(rx=180)) door.mate(f"{c}?Z", name=f"{c}_1", transforms=odict(rx=180)) # add mates to bottom vslot and panel door.mate("panel@faces@<Z", name="panel_0", transforms=odict(rx=180, rz=90)) door.mate("bottom@faces@>X[-4]", name="panel_1") # add mates to handle and one hole door.mate("handle?mate1", name="handle_0", transforms=odict(rx=180)) door.mate("panel?hole1", name="handle_1") check_mates = True if check_mates: show_object(door, name="door") show_mates(door, show_object) else: # Assemble the parts door.assemble("bottom_0", "con_bl_0") # add bottom vslot to bottom-left connector door.assemble("con_br_1", "bottom_1") # add bottom-right connector to bottom vslot door.assemble("left_1", "con_bl_1") # add left vslot to bottom-left connector door.assemble("right_0", "con_br_0") # add right vslot to bottom-right connector door.assemble("panel_0", "panel_1") # add panel door.assemble("con_tl_0", "left_0") # add top-left connector to left vslot door.assemble("con_tr_1", "right_1") # add top-right connector to right vslot door.assemble("top_1", "con_tl_1") # add top vslot to top-left connector door.assemble("handle_0", "handle_1") # add handle show_object(door, name="door")
for name in leg_names: lower, upper, angle = ("top", "bottom", -75) if "left" in name else ("bottom", "top", -75) hexapod.mate(f"{name}?{upper}", name=f"leg_{name}_hole", transforms=odict(rz=angle)) hexapod.mate(f"{name}@faces@<Y", name=f"leg_{name}_hinge", origin=True, transforms=odict(rx=180, rz=-90)) hexapod.mate(f"{name}/lower?{lower}", name=f"leg_{name}_lower_hole", origin=True) check_mates = True if check_mates: show_object(hexapod, name="hexapod") show_mates(hexapod, show_object, length=5) else: # Assemble the parts for leg in leg_names: hexapod.assemble(f"leg_{leg}_lower_hole", f"leg_{leg}_hole") hexapod.assemble(f"leg_{leg}_hinge", f"{leg}_hole") hexapod.assemble("top", "bottom") for stand_name in stand_names: hexapod.assemble(f"{stand_name}", f"{stand_name}_bottom") show_object(hexapod)
("c/b/box2", "box2"), ("c/b/a/box3", "box3"), ("c", "cyl1"), ("c/b", "cyl2"), ("c/b/a", "cyl3"), ): assy.mate( f"{obj}?{name}_m0", name=f"{name}_m0", transforms=odict(rx=180 if "c" in name else 0), origin=True, ) assy.mate(f"{obj}?{name}_m1", name=f"{name}_m1", transforms=odict(rx=0 if "b" in name else 180)) check_mates = True if check_mates: show_object(assy, name="assy") show_mates(assy, show_object, length=2) else: # Assemble the parts assy.assemble("cyl1_m0", "box0_m0") assy.assemble("box1_m1", "cyl1_m1") assy.assemble("cyl2_m0", "box1_m0") assy.assemble("box2_m1", "cyl2_m1") assy.assemble("cyl3_m0", "box2_m0") assy.assemble("box3_m1", "cyl3_m1") show_object(assy)
return assy bearing = create_bearing() # Mates from collections import OrderedDict as odict bearing.mate("outer@faces@<Z", name="outer", origin=True) bearing.mate("inner@faces@<Z", name="inner", origin=True) for i in range(number_balls): bearing.mate(balls[i], Mate(), name=balls[i], origin=True) # the default Mate is sufficient bearing.mate("inner@faces@<Z", name="inner_%d" % i, transforms=odict(rz=i * 60, tx=r5, tz=-ball_diam / 2)) check_mates = True if check_mates: # Assemble the parts show_object(bearing, name="bearing") show_mates(bearing, show_object, length=1) else: bearing.assemble("inner", "outer") for i in range(number_balls): bearing.assemble(balls[i], "inner_%d" % i) show_object(bearing, name="bearing")
name=name, color=C(links[name]["col"]), loc=L(0, 0, i * 10 - 50)) return leg leg = create_leg(x, y) # Mates for name in link_list: leg.mate(f"{name}?mate", name=name, origin=True) check_mates = True if check_mates: show_object(leg, name="leg") show_mates(leg, show_object, length=3) else: # Assemble the parts alpha = 0 joints = linkage(alpha, x, y, links) for name in link_list: v, a = link_loc(name, joints, links) abs_loc = cq.Location( cq.Workplane("YZ").plane.rotated((0, 0, a)), cq.Vector(*v)) # calculate the absolute location ... loc = (abs_loc * leg.mates[name].mate.loc.inverse ) # ... and center the mate of the link first leg.assemble(name, loc) show_object(leg, name="leg")