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

Method hole

cadquery/cq.py:2935–2977  ·  view source on GitHub ↗

Makes a hole for each item on the stack. :param diameter: the diameter of the hole :param depth: the depth of the hole :type depth: float > 0 or None to drill thru the entire part. :param clean: call :meth:`clean` afterwards to have a clean shape Th

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

Source from the content-addressed store, hash-verified

2933 # TODO: almost all code duplicated!
2934 # but parameter list is different so a simple function pointer won't work
2935 def hole(
2936 self: T, diameter: float, depth: Optional[float] = None, clean: bool = True,
2937 ) -> T:
2938 """
2939 Makes a hole for each item on the stack.
2940
2941 :param diameter: the diameter of the hole
2942 :param depth: the depth of the hole
2943 :type depth: float > 0 or None to drill thru the entire part.
2944 :param clean: call :meth:`clean` afterwards to have a clean shape
2945
2946 The surface of the hole is at the current workplane.
2947
2948 One hole is created for each item on the stack. A very common use case is to use a
2949 construction rectangle to define the centers of a set of holes, like so::
2950
2951 s = (
2952 Workplane()
2953 .box(2, 4, 0.5)
2954 .faces(">Z")
2955 .workplane()
2956 .rect(1.5, 3.5, forConstruction=True)
2957 .vertices()
2958 .hole(0.125, 82)
2959 )
2960
2961 This sample creates a plate with a set of holes at the corners.
2962
2963 **Plugin Note**: this is one example of the power of plugins. CounterSunk holes are quite
2964 time consuming to create, but are quite easily defined by users.
2965
2966 see :meth:`cboreHole` and :meth:`cskHole` to make counterbores or countersinks
2967 """
2968 if depth is None:
2969 depth = self.largestDimension()
2970
2971 boreDir = Vector(0, 0, -1)
2972 # first make the hole
2973 h = Solid.makeCylinder(
2974 diameter / 2.0, depth, Vector(), boreDir
2975 ) # local coordinates!
2976
2977 return self.cutEach(lambda loc: h.moved(loc), True, clean)
2978
2979 # TODO: duplicated code with _extrude and extrude
2980 def twistExtrude(

Calls 5

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

Tested by 6

testAngledHolesMethod · 0.64
testCleanMethod · 0.64
testEnclosureMethod · 0.64
testCenterNthSelectorMethod · 0.64