gumyr / cq_warehouse

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

[feature request] Add Fancy Counterbored Holes For Enhanced FDM Printability #42

Open jdegenstein opened 2 years ago

jdegenstein commented 2 years ago

When counterbored holes are 3D printed on an FDM printer in an upside-down orientation they require support material to properly reproduce the circular underside of the larger hole. This feature request is to add a new version of counterbored holes that is better suited to FDM 3D printing by causing the slicer to use bridges instead of unsupported circular extrusions.

image

Example code implementation below for the "positive" version of the shape:

#Fancy 3D Printable Counter-bored Holes
#designed to reduce need for support material
import cadquery as cq

#NOTE: step_dep needs to be at least 0.2mm for typical 3d printer layer height
#NOTE, style1 is best for smaller holes, certainly M3 or less
#NOTE, style2 is better for larger holes, but not tested where the changeover should happen

def fancy_cboreHole_style1(
    caph_diam  = 6.5,#example dimensions are NOT for a particular size screw
    caph_dep   = 2.4,
    step_dep   = 0.4,
    thd_diam   = 3.0, #clearance
    thd_dep    = 3.6,
    ):

    s_p0 = ( #cap head circle
        cq.Sketch()
        .circle(caph_diam/2)
        )

    s_p1 = ( #rect slot with circular cut-ends
        cq.Sketch()
        .circle(caph_diam/2)
        .rect(caph_diam,thd_diam,mode='i')
        )

    s_p2 = ( #thread circle
        cq.Sketch()
        .circle(thd_diam/2)
        )

    f_fancyh = ( #assemble components
        cq.Workplane()
        .placeSketch(s_p0)
        .extrude(caph_dep).faces(">Z").workplane()
        .placeSketch(s_p1)
        .extrude(step_dep).faces(">Z").workplane()
        .placeSketch(s_p2)
        .extrude(thd_dep)
        )
    return f_fancyh

def fancy_cboreHole_style2(
    caph_diam  = 6.5,#example dimensions are NOT for a particular size screw
    caph_dep   = 2.4,
    step_dep   = 0.4, #used everywhere
    thd_diam   = 3.0, #clearance
    thd_dep    = 3.6,
    ):

    #example dimensions above are NOT for a particular size screw
    s_p0 = ( #cap head circle
        cq.Sketch()
        .circle(caph_diam/2)
        )

    s_p1 = ( #rect slot with circular cut-ends
        cq.Sketch()
        .circle(caph_diam/2)
        .rect(caph_diam,thd_diam,mode='i')
        )

    s_p2 = ( #square
        cq.Sketch()
        .rect(thd_diam,thd_diam)
        )

    s_p3 = ( #thread circle
        cq.Sketch()
        .circle(thd_diam/2)
        )

    f_fancyh = ( #assemble components
        cq.Workplane()
        .placeSketch(s_p0)
        .extrude(caph_dep).faces(">Z").workplane()
        .placeSketch(s_p1)
        .extrude(step_dep).faces(">Z").workplane()
        .placeSketch(s_p2)
        .extrude(step_dep).faces(">Z").workplane()
        .placeSketch(s_p3)
        .extrude(thd_dep)
        )
    return f_fancyh

show_object(fancy_cboreHole_style1(),options={"alpha":0.80, "color": (75, 34, 25)})
show_object(fancy_cboreHole_style2().translate((8,0,0)),options={"alpha":0.80, "color": (35, 54, 25)})