gumyr / cq_warehouse

A cadquery parametric part collection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature request] pockets that can prevent nuts from turning

greyltc opened this issue · comments

Like these ones:
nut_capture
image

Here's some example code to consider

import cadquery as cq
import cq_warehouse.fastener as cqf
import cq_warehouse.extensions
import math


MM = 1

nut = cqf.HexNut(size='M6-1', fastener_type='iso4033')

fastener_assembly = cq.Assembly(None, name="plate")

plate_size = (50 * MM, 50 * MM, 20 * MM)
plate = (
    cq.Workplane("XY")
    .box(*plate_size, centered=(True, True, False))
    .faces(">Z")
    .workplane(offset=-nut.nut_thickness)
    .clearanceHole(fastener=nut, counterSunk=False, baseAssembly=fastener_assembly)
)

flat_to_flat = math.sin(60*math.pi/180)*nut.nut_diameter

# most manufacturable:
#plate = plate.faces(">Z").workplane().sketch().slot(flat_to_flat/2, flat_to_flat).finalize().cutBlind(-nut.nut_thickness)

# best use of space:
plate = plate.faces(">Z").workplane().sketch().rect(flat_to_flat,nut.nut_diameter, angle=90).vertices().fillet(nut.nut_diameter/4).finalize().cutBlind(-nut.nut_thickness)


if "show_object" in locals():
    show_object(plate, name="plate", options={"alpha": 0.8})
    show_object(fastener_assembly, name="fastener_assembly")

This example is maximally manufacturable, but not the best use of space around the nut.

image
image

Best space usage is

plate = plate.faces(">Z").workplane().sketch().rect(flat_to_flat,nut.nut_diameter, angle=90).vertices().fillet(nut.nut_diameter/4).finalize().cutBlind(-nut.nut_thickness)

giving
image

Completed with commit 177e0c7