threads-scad icon indicating copy to clipboard operation
threads-scad copied to clipboard

Allow ScrewHole to be called without children

Open yegct opened this issue 2 years ago • 3 comments

@rcolyer,

A small change allowing ScrewHole to be called without children.

This does not affect any existing use. This allows me to generate multiple screw holes in a module and subsequently difference() the entire union, leading to cleaner code. Imagine, a module that generates a pattern of three holes, which we reuse across multiple objects.

// Preexisting functionality, unchanged
ScrewHole(5, 10)
cylinder(h=10,d=10);

// New functionality
translate([10,0,0])
ScrewHole(5, 10);

// More complicated new functionality showing
// hole generation in a method
module many_holes() {
    union() {
        translate([-10,5,0])
        ScrewHole(5,10);
        translate([+10,5,0])
        ScrewHole(5,10);
        translate([0,-10,0])
        ScrewHole(5,10);
    }
}

difference() {
    cylinder(h=10,d=30);
    many_holes();
}

translate([40,0,0])
difference() {
    cube([30,30,20], center=true);
    many_holes();
}

yegct avatar Jan 30 '23 12:01 yegct

@rcolyer Any comments on this?

Tecol87 avatar Aug 22 '23 07:08 Tecol87

I was honestly a little confused at first how to use ScrewHole so I appreciate this feature.

benzvan avatar Feb 23 '24 18:02 benzvan

This worked great. to allow multiple clearance holes to be placed in a single part using a loop!

sbobowski avatar May 02 '24 18:05 sbobowski