コード例 #1
0
def mk_vgroove(cutter_path, entry_point, depth):
    """ for cutting grooves with a 90 degree countersink cutter"""
    half_profile = CQ('XZ').polyline([(0, 0), (depth, 0), (0, -depth)]).close()
    cutter = half_profile.revolve()
    cutter_split = cutter.split(keepTop=True)
    cutter_crosssection = cutter_split.faces('+Y')  #TODO do this more generally
    cutter_crosssection_shift = cutter_crosssection.translate(entry_point)

    to_sweep = cutter_crosssection_shift.wires().toPending()
    sweep_result = to_sweep.sweep(cutter_path, combine=True, transition="round", sweepAlongWires=False, isFrenet=True)
    return sweep_result
コード例 #2
0
    def _make_one_groove(wp, _wire, _vdepth, _ring_cs, _compression_ratio,
                         _gland_fill_ratio):
        cp_tangent = _wire.tangentAt(0)  # tangent to cutter_path
        cp_start = _wire.startPoint()
        build_plane = cq.Plane(origin=cp_start,
                               normal=cp_tangent,
                               xDir=wp.plane.zDir)
        if _vdepth > 0:  # we'll cut a vgroove this deep
            half_profile = CQ(build_plane).polyline([(0, 0), (-_vdepth, 0),
                                                     (0, _vdepth)]).close()
        elif ring_cs > 0:  # we'll cut an o-ring groove, ring_cs is the diameter of the cross section of the o-ring
            # according to https://web.archive.org/web/20220512010502/https://www.globaloring.com/o-ring-groove-design/
            gland_height = get_gland_height(_ring_cs, _compression_ratio)
            gland_width = get_gland_width(_ring_cs, _compression_ratio,
                                          _gland_fill_ratio)
            half_profile = CQ(build_plane).polyline([
                (0, 0), (-gland_height, 0), (-gland_height, gland_width / 2),
                (0, gland_width / 2)
            ]).close()
        else:
            raise ValueError("One of vdepth or ring_cs must be larger than 0")
        cutter = half_profile.revolve(axisEnd=(1, 0, 0))
        cutter_split = cutter.split(keepTop=True)
        faces = cutter_split.faces().vals()
        for face in faces:  # find the right face to sweep with
            facenorm = face.normalAt()
            dotval = facenorm.dot(cp_tangent)
            if abs(
                (abs(dotval) - 1)
            ) <= 0.001:  # allow for small errors in orientation calculation
                cutter_crosssection = face
                break
        else:
            raise ValueError("Unable to find a cutter cross-section")

        # make the squished o-ring hardware
        if (ring_cs > 0) and (hardware is not None):
            ring_sweep_wire = CQ(build_plane).center(
                -gland_height / 2,
                0).ellipse(gland_height / 2, ring_cs / 2 *
                           (1 + _compression_ratio)).wires().toPending()
            hardware.add(
                ring_sweep_wire.sweep(_wire,
                                      combine=True,
                                      transition="round",
                                      isFrenet=True).findSolid())

        to_sweep = CQ(cutter_crosssection).wires().toPending()
        return to_sweep.sweep(_wire).findSolid()