[Feature Request] Add support for threaded insert hole
afshawnlotfi opened this issue · comments
Would be nice to have a threaded insert hole
Complete in the dev branch (will be in released 0.5.3):
class HeatSetNut(Nut):
"""Heat Set Nut
Args:
size (str): nut size, e.g. M5-0.8-Standard
fastener_type (str): standard or manufacturer that defines the nut ["McMaster-Carr"]
hand (Literal["right", "left"], optional): direction of thread. Defaults to "right".
simple (bool): omit the thread from the nut. Defaults to True.
Attributes:
fill_factor (float): Fraction of insert hole filled with heatset nut
"""
along with an insertHole()
Workplane method to use them:
def _insertHole(
self: T,
fastener: "Nut",
fit: Optional[Literal["Close", "Normal", "Loose"]] = "Normal",
depth: Optional[float] = None,
baseAssembly: Optional["Assembly"] = None,
clean: Optional[bool] = True,
manufacturingCompensation: float = 0.0,
) -> T:
Together with the new BradTeeNut, one can do:
import cadquery as cq
from cq_warehouse.fastener import BradTeeNut, CounterSunkScrew, HeatSetNut
import cq_warehouse.extensions
MM = 1
# Create the fasteners used in this example
bradtee_nut = BradTeeNut(size="M8-1.25", fastener_type="Hilitchi", simple=False)
brad = CounterSunkScrew(
size=bradtee_nut.nut_data["brad_size"],
length=20 * MM,
fastener_type="iso10642",
simple=False,
)
heatset = HeatSetNut(
size=bradtee_nut.nut_data["brad_size"] + "-Standard",
fastener_type="McMaster-Carr",
simple=True,
)
# Create an empty Assembly to hold all of the fasteners
fastener_assembly = cq.Assembly(None, name="plate")
# Create a simple plate with appropriate holes to house all the fasteners
plate_size = (50 * MM, 50 * MM, 20 * MM)
plate = (
cq.Workplane("XY")
.box(*plate_size, centered=(True, True, False))
.faces(">Z")
.workplane()
.clearanceHole(fastener=bradtee_nut, baseAssembly=fastener_assembly)
.polarArray(
bradtee_nut.nut_data["bcd"] / 2, 0, 360, bradtee_nut.nut_data["brad_num"]
)
.clearanceHole(fastener=brad, baseAssembly=fastener_assembly)
# Place HeatSetNuts for the brads on the bottom of the plate
.pushFastenerLocations(
fastener=brad,
baseAssembly=fastener_assembly,
offset=-plate_size[2],
flip=True,
)
.insertHole(fastener=heatset, baseAssembly=fastener_assembly)
)
print(fastener_assembly.fastenerQuantities())
print(HeatSetNut.sizes("McMaster-Carr"))
if "show_object" in locals():
show_object(plate, name="plate", options={"alpha": 0.8})
show_object(fastener_assembly, name="fastener_assembly")
Awesome work!