discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Help with difference of an object from an object generated by an module

SV
sorin vatasoiu
Fri, Apr 16, 2021 3:52 AM

Hi,I want to model a curved surface and create a hole in it (around the middle of it)I have the code that should create this, but instead of difference, it seems to combine the objects.
Here is the code:the module curvedBase does create a curved surface and rotate it in the horizontal planethe module main should cut a cylinder from the surface generated by the curved moduleThe result I get are the 2 combined objects, not the difference
Any help is welcomed. 

---=======$fn= 360;
w  = 40;      // width of rectangleh  =   2;      // height of rectanglel  =  90;      // length of chord of the curvedh =   4;      // delta height of the curve
main();
module main(){  difference(){    curvedBase();          translate([0,20,0])      cylinder(  20,r1=10, d2=20, center=true);  }}
module curve(width, height, length, dh) {    r = (pow(length/2, 2) + pow(dh, 2))/(2dh);    a = 2asin((length/2)/r);    translate([-(r -dh), 0, -width/2]) rotate([0, 0, -a/2])         rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);}
module curvedBase(){  rotate([0,-90,90])    curve(w, h, l, dh);}

Hi,I want to model a curved surface and create a hole in it (around the middle of it)I have the code that should create this, but instead of difference, it seems to combine the objects. Here is the code:the module curvedBase does create a curved surface and rotate it in the horizontal planethe module main should cut a cylinder from the surface generated by the curved moduleThe result I get are the 2 combined objects, not the difference Any help is welcomed.  ========================================$fn= 360; w  = 40;      // width of rectangleh  =   2;      // height of rectanglel  =  90;      // length of chord of the curvedh =   4;      // delta height of the curve main(); module main(){  difference(){    curvedBase();          translate([0,20,0])      cylinder(  20,r1=10, d2=20, center=true);  }} module curve(width, height, length, dh) {    r = (pow(length/2, 2) + pow(dh, 2))/(2*dh);    a = 2*asin((length/2)/r);    translate([-(r -dh), 0, -width/2]) rotate([0, 0, -a/2])         rotate_extrude(angle = a) translate([r, 0, 0]) square(size = [height, width], center = true);} module curvedBase(){  rotate([0,-90,90])    curve(w, h, l, dh);}