discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: preview difference() glitch

RW
Roger Whiteley
Fri, Dec 23, 2022 11:13 AM

Chris, aka nop.head - your tip about viewing in Orthogonal instead of
Perspective is worthy of a Big Thank You - a festive tipple of your
choice, pint of Robinson's perhaps?

If I am differencing cylinders to make a tube, I use a default offset of
0.1, but assigned to a 'constant', which I called cd, then I make the
length of the inner cylinder plus 2xcd.  It makes offsetting so much
easier when I use a module that makes the hole and puts a chamfer either
side of the hole thus:

module chamfered_hole_45 (hole_dia,plate_thick,hole_cham=1,bolt_round=40) {
  echo (hole_dia,plate_thick,hole_cham,bolt_round);

    //bolt_round = 40;
    hole_depth = 2plate_thick ;// just makes a long pole :-)
    l_hole_dia = hole_dia;
    l_hole_cham = hole_cham;
    echo (hole_depth=hole_depth);
    echo (bolt_round=bolt_round);
cylinder(d1=l_hole_dia+l_hole_cham
2,d2=l_hole_dia,h=l_hole_cham,$fn=bolt_round);
    cylinder_outer (l_hole_dia/2,hole_depth+1,bolt_round);
    translate([0,0,plate_thick-l_hole_cham])
cylinder(d1=l_hole_dia,d2=l_hole_dia+l_hole_cham*2,h=l_hole_cham,$fn=bolt_round);

}//end module

cylinder_outer is another module that compensates for the geometry going
round the inside of the 'hole' and making it undersize.

module cylinder_outer(radius,height,fn){
   fudge = 1/cos(180/fn);
   cylinder(h=height,r=radius*fudge,$fn=fn);}

Compliments of the season to all our readers ;-)

Roger

Chris, aka nop.head - your tip about viewing in Orthogonal instead of Perspective is worthy of a Big Thank You - a festive tipple of your choice, pint of Robinson's perhaps? If I am differencing cylinders to make a tube, I use a default offset of 0.1, but assigned to a 'constant', which I called cd, then I make the length of the inner cylinder plus 2xcd.  It makes offsetting so much easier when I use a module that makes the hole and puts a chamfer either side of the hole thus: module chamfered_hole_45 (hole_dia,plate_thick,hole_cham=1,bolt_round=40) {   echo (hole_dia,plate_thick,hole_cham,bolt_round);     //bolt_round = 40;     hole_depth = 2*plate_thick ;// just makes a long pole :-)     l_hole_dia = hole_dia;     l_hole_cham = hole_cham;     echo (hole_depth=hole_depth);     echo (bolt_round=bolt_round); cylinder(d1=l_hole_dia+l_hole_cham*2,d2=l_hole_dia,h=l_hole_cham,$fn=bolt_round);     cylinder_outer (l_hole_dia/2,hole_depth+1,bolt_round);     translate([0,0,plate_thick-l_hole_cham]) cylinder(d1=l_hole_dia,d2=l_hole_dia+l_hole_cham*2,h=l_hole_cham,$fn=bolt_round); }//end module cylinder_outer is another module that compensates for the geometry going round the inside of the 'hole' and making it undersize. module cylinder_outer(radius,height,fn){    fudge = 1/cos(180/fn);    cylinder(h=height,r=radius*fudge,$fn=fn);} Compliments of the season to all our readers ;-) Roger