gumyr / cq_warehouse

A cadquery parametric part collection
Apache License 2.0
107 stars 23 forks source link

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

Open greyltc opened 2 years ago

greyltc commented 2 years ago

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

jpoles1 commented 1 year ago

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
jpoles1 commented 1 year ago

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.