コード例 #1
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
コード例 #2
0
ファイル: block_tree.py プロジェクト: zignig/cqparts
 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))))
コード例 #3
0
    def make(self):
        pin = cq.Workplane("XY").box(self.pin_width, self.slot_height,
                                     self.slot_height)

        top_wall = pin.edges(">Z and <Y").workplane().box(
            self.length,
            self.width,
            self.height - self.slot_height,
            centered=(True, False, False),
            combine=False)

        slot_wall = pin.faces(">Y").workplane(). \
            rect(self.pin_width + self.slot_width * 2, self.slot_height). \
            extrude(self.width - self.slot_height, combine=False)

        right_edge_plane = cq.Workplane("XY")
        right_edge_plane = right_edge_plane.transformed(
            offset=right_edge_plane.toLocalVector(slot_wall.vertices(
                ">X"), top_wall.vertices("<Y"), pin.vertices("<Z")))
        right_edge = right_edge_plane.rect(
            right_edge_plane.toLocalVector(top_wall.vertices(">X")).x,
            self.width,
            centered=False).\
            extrude(self.slot_height)

        pin_plane = (pin.faces("<Y").workplane().plane)
        self._mate = cp.constraint.Mate(self,
                                        CoordSystem.from_plane(pin_plane))

        pin = pin.edges("<Z and |Y").fillet(self.pin_width / 2 - 0.0001)
        pin = pin.edges("<Y and |Z").chamfer(self.chamfer)
        pin = pin.edges("<Y and >Z").chamfer(self.chamfer)

        ret = slot_wall.union(top_wall)
        ret = ret.union(right_edge)
        ret = ret.union(right_edge.mirror(mirrorPlane="YZ"))

        ret = ret.edges().chamfer(self.chamfer)
        ret = ret.union(pin)

        return ret
コード例 #4
0
 def mate_axle(self):
     plane = self.local_obj.faces(">Z").workplane().plane
     return Mate(self, CoordSystem.from_plane(plane))