Example #1
0
    def make_constraints(self):
        constraints = [
            Fixed(
                self.components["glass_top"].mate_origin,
                CoordSystem((0, 0, self.height), (1, 0, 0), (0, 0, 1)),
            ),
            Fixed(
                self.components["shelf_0"].mate_origin,
                CoordSystem((0, 0, self.height_1), (1, 0, 0), (0, 0, 1)),
            ),
            Fixed(
                self.components["shelf_1"].mate_origin,
                CoordSystem((0, 0, self.height_2), (1, 0, 0), (0, 0, 1)),
            ),
            Coincident(
                self.components["leg_0"].mate_origin,
                self.components["glass_top"].mate_leg_0,
            ),
            Coincident(
                self.components["leg_1"].mate_origin,
                self.components["glass_top"].mate_leg_1,
            ),
            Coincident(
                self.components["leg_2"].mate_origin,
                self.components["glass_top"].mate_leg_2,
            ),
            Coincident(
                self.components["leg_3"].mate_origin,
                self.components["glass_top"].mate_leg_3,
            ),
        ]

        return constraints
Example #2
0
 def make_constraints(self):
     board = self.components["board"]
     constr = [
         Fixed(
             board.mate_origin,
             CoordSystem(origin=(0, 0,
                                 self.standoff + board.thickness / 2)),
         )
     ]
     for i, j in enumerate(board.mount_verts()):
         m = Mate(
             self,
             CoordSystem(
                 origin=(j.X, j.Y, self.standoff + board.thickness),
                 xDir=(1, 0, 0),
                 normal=(0, 0, 1),
             ),
         )
         constr.append(
             Coincident(self.components[self.screw_name(i)].mate_origin,
                        m)),
         constr.append(
             Coincident(
                 self.components[self.standoff_name(i)].mate_top(),
                 Mate(
                     self,
                     CoordSystem(
                         origin=(j.X, j.Y, self.standoff),
                         xDir=(1, 0, 0),
                         normal=(0, 0, 1),
                     ),
                 ),
             ))
     return constr
Example #3
0
 def make_constraints(self):
     return [
         Fixed(
             self.components["holder"].mate_origin,
             CoordSystem((0, 0, 0), (1, 0, 0), (0, 0, 1)),
         ),
         Coincident(
             self.components["bolt"].mate_along(
                 0),
             # self.components["holder"].mate_origin,  # Put nut at end
             self.components["holder"].mate_bolt,
         ),
         # Fixed(  # Test  bolt
         #     self.components["bolt"].mate_origin,
         #     CoordSystem((20, 30, 0), (0, 0, 1), (1, 0, 0)).rotated((0, 0, 0)),
         # ),
         Coincident(  # Move motor
             self.components["motor"].mate_origin,
             self.components["holder"].mate_motor,
         ),
         Coincident(
             self.components["gear"].mate_shaft, self.components["motor"].mate_gear
         ),
         Fixed(  # Move riser
             self.components["riser_holder"].mate_origin,
             CoordSystem((7.5+14.7/2.0, -18.4, 0), (-1, 0, 0), (0, 0, 1)).rotated((0, 0, 180)),
         ),
         Coincident(  # mount
             self.components["riser"].mate_holder_demo,
             self.components["riser_holder"].mate_origin,
         ),
         Fixed(
             self.components["switch"].mate_origin,
             CoordSystem((0, -7, 3), xDir=(0, 0, 1), normal=(-1, 0, 0)).rotated((90, 0, 0)), )
     ]
Example #4
0
 def make_constraints(self):
     constr = []
     for i in range(self.count):
         el = self.components[self.electrode_name(i)]
         constr.append(
             Fixed(
                 el.mate_origin,
                 CoordSystem().rotated((0, 0, i * self.incr)) +
                 CoordSystem(origin=(self.radius, 0, 0)),
             ))
     return constr
Example #5
0
 def make_constraints(self):
     base2 = self.components["base2"]
     base3 = self.components["base3"]
     constraints = [
         Fixed(self.components["base"].mate_origin, CoordSystem(
             (0, 107, 0))),
         Fixed(base2.mate_origin, CoordSystem(
             (0, 147, 0))),  # Embed nuts in top and make sure cutout
         Fixed(base3.mate_origin, CoordSystem(
             (0, 180, 0))),  # Embed nuts in top and make sure cutout
         # works
     ]
     for i, size in enumerate(self.tests):
         bolt_b = self.components[self.bolt_on_bottom_name(size)]
         constraints += [
             Fixed(  # Space out nuts
                 self.components[self.nut_name(size)].mate_origin,
                 CoordSystem((i * 20, 0, 0)),
             ),
             Fixed(
                 self.components[self.thread_name(size)].mate_origin,
                 CoordSystem((i * 20, 15, 0)),
             ),
             Fixed(
                 self.components[self.min_bolt_name(size)].mate_origin,
                 CoordSystem((i * 20, 40, 0)),
             ),
             Fixed(
                 self.components[self.bolt_name(size)].mate_origin,
                 CoordSystem((i * 20, 65, 0)),
             ),
             Fixed(
                 self.components[self.embedded_bolt_name(size)].mate_origin,
                 CoordSystem((i * 20, 95, 0)),
             ),
             Fixed(
                 self.components[self.insert_bolt_name(size)].mate_origin,
                 CoordSystem((i * 20, 120, 10)),
             ),
             Fixed(
                 self.components[self.tool_name(size)].mate_origin,
                 CoordSystem((i * 20, -10, 0)),
             ),
             Coincident(
                 self.components[self.nut_on_top_name(size)].mate_nutend,
                 base2.mate_nut_top(i),
             ),
             Coincident(
                 bolt_b.mate_head_end(rotation=(180, 0, 0)),
                 base3.mate_nut_bottom(i),
             ),
         ]
     return constraints
Example #6
0
 def make_constraints(self):
     return [
         Fixed(self.components['chassis'].mate_origin),
         Coincident(
             self.components['front_axle'].mate_origin,
             Mate(self.components['chassis'], CoordSystem((self.wheelbase/2,0,0))),
         ),
         Coincident(
             self.components['rear_axle'].mate_origin,
             Mate(self.components['chassis'], CoordSystem((-self.wheelbase/2,0,0))),
         ),
     ]
Example #7
0
    def make(self):
        top = cq.Workplane("XY").box(self.width,
                                     self.toggle_width + self.extra_space,
                                     self.wall_thickness)
        back = (top.faces(">Z").workplane(invert=True).transformed(
            origin=(None, top.vertices(">Y"), None),
            offset=(0, -self.wall_thickness,
                    0)).box(self.width,
                            self.wall_thickness,
                            self.toggle_height + self.extra_space +
                            2 * self.wall_thickness,
                            centered=[True, False, False],
                            combine=False))
        front = back.mirror(mirrorPlane="XZ").translate((0, 0, 0))
        left_bottom = (back.faces("<Z").workplane(invert=True).transformed(
            origin=(front.vertices("<X"), front.vertices(">Y"), None), ).box(
                (self.width - self.slot_width) / 2,
                self.toggle_width + self.extra_space,
                self.wall_thickness,
                combine=False,
                centered=(False, False, False)))
        right_bottom = left_bottom.mirror(mirrorPlane="YZ")

        front_mount_bracket = (front.faces("<Z").workplane().box(
            self.bracket_width,
            self.wall_thickness,
            self.bracket_height,
            combine=False,
            centered=(True, True, False)).faces(">Y").workplane().transformed(
                origin=(None, None, top.faces("<Z")),
                offset=(0, -self.extra_space - self.probe_hole_distance,
                        0)).hole(self.mount_hole_diameter))

        rear_mount_bracket = front_mount_bracket.mirror(mirrorPlane="XZ")

        toggle_plane = (right_bottom.faces(">Z").workplane().transformed(
            origin=(0, None, None)).plane)
        self._toggle_mate = cp.constraint.Mate(
            self, CoordSystem.from_plane(toggle_plane))

        probe_plane = (front_mount_bracket.faces(">Y").workplane().transformed(
            origin=(None, None, top.faces("<Z")),
            offset=(0, -self.extra_space - self.probe_hole_distance, 0)).plane)
        self._probe_mate = cp.constraint.Mate(
            self, CoordSystem.from_plane(probe_plane))

        ret = (top.union(back).union(left_bottom).union(right_bottom).union(
            rear_mount_bracket))

        if not self.hide_front:
            ret = ret.union(front).union(front_mount_bracket)
        return ret
Example #8
0
 def make_constraints(self):
     constr = [
         Fixed(self.components["mount"].mate_origin),
         Coincident(
             self.components["stepper"].mate_origin,
             self.components["mount"].mate_motor(),
         ),
     ]
     # if driven is defined
     if self.driven is not None:
         shaft_length = self.stepper().shaft_length
         constr.append(
             Coincident(
                 self.components["driven"].mate_wheel(),
                 self.components["mount"].mate_motor(offset=shaft_length),
             ))
     # if the mount is defined add the
     mnt = self.find("mount")
     if self.target is not None:
         for i, j in enumerate(self.components["mount"].mount_points()):
             m = Mate(
                 self,
                 CoordSystem(
                     origin=(j.X, j.Y, -mnt.thickness),
                     xDir=(1, 0, 0),
                     normal=(0, 0, -1),
                 ),
             )
             constr.append(
                 Coincident(self.components[self.mount_name(i)].mate_origin,
                            m))
     # screws for stepper to mount
     for i, j in enumerate(self.components["stepper"].mount_points()):
         m = Mate(
             self,
             CoordSystem(
                 origin=(
                     j.X,
                     -mnt.length / 2,
                     j.Y + mnt.height / 2 + mnt.clearance / 2 +
                     mnt.thickness,
                 ),
                 xDir=(1, 0, 0),
                 normal=(0, -1, 0),
             ),
         )
         constr.append(
             Coincident(self.components[self.screw_name(i)].mate_origin, m))
     return constr
Example #9
0
 def roller_mounts(self):
     mounts = []
     self.make()
     for i in range(self.rollers):
         m = Mate(
             self,
             CoordSystem.from_transform(self.mp[i]) + CoordSystem(
                 origin=(0, 0,
                         self.mount_thickness / 2 - self.roller_length / 2),
                 xDir=(1, 0, 0),
                 normal=(0, 0, 1),
             ),
         )
         mounts.append(m)
     return mounts
Example #10
0
 def mate_motor(self):
     return Mate(
         self,
         CoordSystem(origin=(self.motor_offset, 0, 0),
                     xDir=(0, 0, 1),
                     normal=(-1, 0, 0)),
     )
Example #11
0
 def mate_holder(self):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, 0),
                     # xDir=(1, 0, 0), normal=(0, 0, 1),
                     ),
     )
Example #12
0
 def mate_tip(self):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.shaft_length),
                     xDir=(1, 0, 0),
                     normal=(0, 0, 1)),
     )
Example #13
0
 def mate_tip(self, offset=0):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.length),
                     xDir=(1, 0, 0),
                     normal=(0, 0, 1)),
     )
Example #14
0
    def make_constraints(self):
        return [
            # trunk
            Fixed(
                self.components['trunk'].mate_origin,  # lock this
                CoordSystem((0, 0, 0), (1, 0, 0), (0, 0, 1)),  # here
            ),
            Coincident(
                self.components['trunk_split'].mate_origin,  # lock this
                self.components['trunk'].mate_top,  # here
            ),

            # branch L
            Coincident(
                self.components['branch_lb'].mate_origin,
                self.components['trunk_split'].mate_left,
            ),
            Coincident(
                self.components['branch_ls'].mate_origin,
                self.components['branch_lb'].mate_top,
            ),

            # branch RL
            Coincident(
                self.components['branch_r'].mate_origin,
                self.components['trunk_split'].mate_right,
            ),
        ]
Example #15
0
 def mate_gear(self):
     """This is at the centre and end of the drive shaft"""
     return Mate(
         self,
         CoordSystem(origin=(8.5, 0, 26.75),
                     xDir=(1, 0, 1),
                     normal=(0, 0, -1)))
Example #16
0
 def make_constraints(self):
     constr = [
         Fixed(self.components["shaft"].mate_origin,
               CoordSystem(origin=(0, 0, 0))),
         Fixed(self.components["roller"].mate_end()),
     ]
     return constr
Example #17
0
 def mate_right(self):
     return Mate(
         self,
         CoordSystem(origin=(0, self.length / 2, 0),
                     xDir=(1, 0, 0),
                     normal=(0, 1, 0)),
     )
Example #18
0
 def mate_top(self):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.thickness),
                     xDir=(1, 0, 0),
                     normal=(0, 0, 1)),
     )
Example #19
0
 def mate_holder(self):
     return Mate(
         self,
         CoordSystem(origin=(-90, 17.5, 128),
                     xDir=(1, 0, 0),
                     normal=(0, -1, 0)),
     )
Example #20
0
 def mate_two(self):
     return Mate(
         self,
         CoordSystem(origin=(0, -11, 0),
                     # xDir=(1, 0, 0), normal=(0, -1, 0),
                     ),
     )
Example #21
0
 def mate_output(self, offset=0):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.gap / 2),
                     xDir=(1, 0, 0),
                     normal=(0, 0, 1)),
     )
Example #22
0
 def mate_centre(self):
     """Assumes rotating around Z axis"""
     return Mate(
         self,
         CoordSystem(origin=(0, 0, +self.width / 2),
                     #            xDir=(1, 0, 0), normal=(0, -1, 0),
                     ))
Example #23
0
 def mate_left(self):
     return Mate(
         self,
         CoordSystem(origin=(0, self.seperation / 2, 0),
                     xDir=(1, 0, 0),
                     normal=(0, -1, 0)),
     )
Example #24
0
 def mate_end(self, offset=0):
     return Mate(
         self,
         CoordSystem(origin=(-self.length / 2, 0, 0),
                     xDir=(0, 0, 1),
                     normal=(1, 0, 0)),
     )
Example #25
0
 def mate_beam2(self):
     return Mate(
         self,
         CoordSystem(origin=(10, 17.5, 128),
                     xDir=(0, -1, 0),
                     normal=(-1, 0, 0)),
     )
Example #26
0
 def make_constraints(self):
     constraints = [
         Fixed(self.components["base"].mate_origin, CoordSystem()),
         Fixed(self.components["switch1"].mate_origin,
               CoordSystem((0, -30, 0))),
         Fixed(
             self.components["switch2"].mate_origin,
             CoordSystem((0, 15, 0), xDir=(0, 0, 1),
                         normal=(-1, 0, 0)).rotated((90, 0, 0)),
         )
         # Fixed(  # Space out nuts
         #     self.components["switch2"].mate_origin,
         #     CoordSystem((0, 0, 0), xDir=(0, 1, 0), normal=(1, 0, 0)),
         # ),
     ]
     return constraints
Example #27
0
 def make_constraints(self):
     constr = [
         Fixed(self.components["base"].mate_origin,
               CoordSystem(origin=(0, 0, 60))),
         Coincident(
             self.components["electronics"].mate_origin,
             self.components["base"].mate_back(),
         ),
         Coincident(
             self.components["sensors"].mate_front(),
             self.components["base"].mate_front(),
         ),
         Coincident(
             self.components["Ldrive_b"].mate_corner(flip=-1),
             self.components["base"].mate_RL(),
         ),
         Coincident(
             self.components["Rdrive_b"].mate_corner(flip=1),
             self.components["base"].mate_RR(),
         ),
         Coincident(
             self.components["Ldrive_f"].mate_corner(flip=1),
             self.components["base"].mate_RL(offset=self.length -
                                             self.chamfer),
         ),
         Coincident(
             self.components["Rdrive_f"].mate_corner(flip=-1),
             self.components["base"].mate_RR(offset=self.length -
                                             self.chamfer),
         ),
     ]
     return constr
Example #28
0
 def pulley_B_mate(self, offset=0):
     return Mate(
         self,
         CoordSystem(origin=(-offset, -self.spacing, 0),
                     xDir=(0, 1, 0),
                     normal=(1, 0, 0)),
     )
Example #29
0
 def mate_top(self):
     # Mate point at the top of the cylinder, twist applied
     return Mate(
         self,
         CoordSystem.from_plane(
             self.local_obj.faces(">Z").workplane().plane.rotated(
                 (0, 0, self.twist))))
Example #30
0
 def mate_top(self):
     return Mate(
         self,
         CoordSystem(origin=(0, 0, self.height),
                     xDir=(1, 0, 0),
                     normal=(0, 0, -1)),
     )