MCPcopy
hub / github.com/CadQuery/cadquery / cboreHole

Method cboreHole

cadquery/cq.py:2814–2869  ·  view source on GitHub ↗

Makes a counterbored hole for each item on the stack. :param diameter: the diameter of the hole :param cboreDiameter: the diameter of the cbore, must be greater than hole diameter :param cboreDepth: depth of the counterbore :type cboreDepth: float > 0

(
        self: T,
        diameter: float,
        cboreDiameter: float,
        cboreDepth: float,
        depth: Optional[float] = None,
        clean: bool = True,
    )

Source from the content-addressed store, hash-verified

2812 # TODO: almost all code duplicated!
2813 # but parameter list is different so a simple function pointer won't work
2814 def cboreHole(
2815 self: T,
2816 diameter: float,
2817 cboreDiameter: float,
2818 cboreDepth: float,
2819 depth: Optional[float] = None,
2820 clean: bool = True,
2821 ) -> T:
2822 """
2823 Makes a counterbored hole for each item on the stack.
2824
2825 :param diameter: the diameter of the hole
2826 :param cboreDiameter: the diameter of the cbore, must be greater than hole diameter
2827 :param cboreDepth: depth of the counterbore
2828 :type cboreDepth: float > 0
2829 :param depth: the depth of the hole
2830 :type depth: float > 0 or None to drill thru the entire part
2831 :param clean: call :meth:`clean` afterwards to have a clean shape
2832
2833 The surface of the hole is at the current workplane plane.
2834
2835 One hole is created for each item on the stack. A very common use case is to use a
2836 construction rectangle to define the centers of a set of holes, like so::
2837
2838 s = (
2839 Workplane()
2840 .box(2, 4, 0.5)
2841 .faces(">Z")
2842 .workplane()
2843 .rect(1.5, 3.5, forConstruction=True)
2844 .vertices()
2845 .cboreHole(0.125, 0.25, 0.125, depth=None)
2846 )
2847
2848 This sample creates a plate with a set of holes at the corners.
2849
2850 **Plugin Note**: this is one example of the power of plugins. Counterbored holes are quite
2851 time consuming to create, but are quite easily defined by users.
2852
2853 see :meth:`cskHole` to make countersinks instead of counterbores
2854 """
2855 if depth is None:
2856 depth = self.largestDimension()
2857
2858 boreDir = Vector(0, 0, -1)
2859 center = Vector()
2860 # first make the hole
2861 hole = Solid.makeCylinder(
2862 diameter / 2.0, depth, center, boreDir
2863 ) # local coordinates!
2864
2865 # add the counter bore
2866 cbore = Solid.makeCylinder(cboreDiameter / 2.0, cboreDepth, Vector(), boreDir)
2867 r = hole.fuse(cbore)
2868
2869 return self.cutEach(lambda loc: r.moved(loc), True, clean)
2870
2871 # TODO: almost all code duplicated!

Calls 6

largestDimensionMethod · 0.95
cutEachMethod · 0.95
VectorClass · 0.85
makeCylinderMethod · 0.80
fuseMethod · 0.45
movedMethod · 0.45

Tested by 2

testCounterBoresMethod · 0.64
testEnclosureMethod · 0.64