gumyr / cq_warehouse

A cadquery parametric part collection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature request] add variable countersinking to `clearanceHole()`

greyltc opened this issue · comments

Today, clearanceHole() with counterSunk=True puts the top of the fastener exactly at the workplane and counterSunk=False puts the bottom of the fastener's head at the workplane.

It would be a neat addition if the counterSunk keyword could take a float as well to allow some more control over the precise Z position of the fastener (along with correct cutting of the work piece), with counterSunk=0 being the same as False and counterSunk=fastener.head_height being the same as True.

As it it now, achieving an "over countersunk" screw hole like this is a bit tricky to achieve:
image

Agreed, this is some essential functionality I'd love to see! It's relatively easy to get this done with nuts, but strugling a bit to get it working with screw heads. I think it'd involve messing around withe the countersink_profile functionality which I do not yet understand.

For nuts, adding a variable to the _fastenerHole function (which I'm calling countersinkDepth) and changing:

        head_offset = countersink_profile.vertices(">Z").val().Z

to

        head_offset = countersinkDepth if countersinkDepth else countersink_profile.vertices(">Z").val().Z

Still need to test a bunch of cases for compatibility, but I think this commit adds functionality that should cover most cases for variable depth countersinking.

Just add countersinkDepth=___ to your clearanceHole() or fastenerHole() function to set a variable depth.