discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Cylinder difference not working

RB
Robert Brown
Mon, Jul 18, 2022 4:17 AM

Hi

Thanks for the support forum/mailing list.

I have a problem getting a difference function to work with a translated
cylinder in that it does not do the expected thing of creating a
cylindrical hole (penetration). It does a partial hole depending upon
the translate z-axis height but no combination of cylinder height of
translate height yields the expected result. Seems I am not
understanding something about the interaction. Tried using hull() and I
also find the cube() will "difference" as expected.

Thanks for any pointers.

pcb_width=60;
pcb_length=88;
pcb_thickness=1.8;
pcb_height=22; // including the usb ports
case_thickness=2;
width=pcb_width+case_thickness2;
length=pcb_length+case_thickness;
height=pcb_height+case_thickness
2;
module case() {
        // body
    translate([-width/2,-length/2,0])
        difference() {
            cube([width,length,height]);
            translate([case_thickness,-0.01,case_thickness])
                cube([pcb_width,pcb_length,pcb_height]);
//            translate([15,15,height-2.2])
            hull()
            translate([width/2,length/2,25.01])
                cylinder(h = 8, r = pcb_width/2-1, true,$fn=60);
//                 cube([30,60,4.5]);
    }
}

case();

Cheers

Rob B

--
Zero emissions by 2050 for a safe climate future.

Hi Thanks for the support forum/mailing list. I have a problem getting a difference function to work with a translated cylinder in that it does not do the expected thing of creating a cylindrical hole (penetration). It does a partial hole depending upon the translate z-axis height but no combination of cylinder height of translate height yields the expected result. Seems I am not understanding something about the interaction. Tried using hull() and I also find the cube() will "difference" as expected. Thanks for any pointers. pcb_width=60; pcb_length=88; pcb_thickness=1.8; pcb_height=22; // including the usb ports case_thickness=2; width=pcb_width+case_thickness*2; length=pcb_length+case_thickness; height=pcb_height+case_thickness*2; module case() {         // body     translate([-width/2,-length/2,0])         difference() {             cube([width,length,height]);             translate([case_thickness,-0.01,case_thickness])                 cube([pcb_width,pcb_length,pcb_height]); //            translate([15,15,height-2.2])             hull()             translate([width/2,length/2,25.01])                 cylinder(h = 8, r = pcb_width/2-1, true,$fn=60); //                 cube([30,60,4.5]);     } } case(); Cheers Rob B -- Zero emissions by 2050 for a safe climate future.
MM
Michael Marx
Mon, Jul 18, 2022 4:37 AM

You need named parameters for center in the cylinder() because of the r v,s r1,r2 options.
You have a choice, either position it centered and use center=true so it grows up/down equally to cut.
Or position it just below and make it go up by the thickness, plus a small margin (0.01 & 0.02 as per below).
You don't need hull() here,
but note with the commented out cobe() you would need
hull() {} i.e. both in curly braces.


pcb_width=60;
pcb_length=88;
pcb_thickness=1.8;
pcb_height=22; // including the usb ports
case_thickness=2;
width=pcb_width+case_thickness2;
length=pcb_length+case_thickness;
height=pcb_height+case_thickness
2;
echo(width=width,length=length,height=height);
module case() {
// body
translate([-width/2,-length/2,0])
difference() {
cube([width,length,height]);
translate([case_thickness,-0.01,case_thickness])
cube([pcb_width,pcb_length,pcb_height]);
//            translate([15,15,height-2.2])
//hull()
translate([width/2,length/2,height-case_thickness-0.01]) // <====
#cylinder(h = case_thickness+0.02,                  // <====
r = pcb_width/2-1,
center=false,                              // <====
$fn=60);
//                cube([30,60,4.5]);
}
}
case();

-----Original Message-----
From: Robert Brown [mailto:rebrown@exemail.com.au]
Sent: Mon, 18 Jul 2022 14:17
To: discuss@lists.openscad.org
Subject: [OpenSCAD] Cylinder difference not working

Hi

Thanks for the support forum/mailing list.

I have a problem getting a difference function to work with a translated
cylinder in that it does not do the expected thing of creating a
cylindrical hole (penetration). It does a partial hole depending upon
the translate z-axis height but no combination of cylinder height of
translate height yields the expected result. Seems I am not
understanding something about the interaction. Tried using hull() and I
also find the cube() will "difference" as expected.

Thanks for any pointers.

pcb_width=60;
pcb_length=88;
pcb_thickness=1.8;
pcb_height=22; // including the usb ports
case_thickness=2;
width=pcb_width+case_thickness2;
length=pcb_length+case_thickness;
height=pcb_height+case_thickness
2;
module case() {
// body
translate([-width/2,-length/2,0])
difference() {
cube([width,length,height]);
translate([case_thickness,-0.01,case_thickness])
cube([pcb_width,pcb_length,pcb_height]);
//            translate([15,15,height-2.2])
hull()
translate([width/2,length/2,25.01])
cylinder(h = 8, r = pcb_width/2-1, true,$fn=60);
//                cube([30,60,4.5]);
}
}

case();

Cheers

Rob B

--
Zero emissions by 2050 for a safe climate future.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG.
https://www.avg.com

You need named parameters for center in the cylinder() because of the r v,s r1,r2 options. You have a choice, either position it centered and use center=true so it grows up/down equally to cut. Or position it just below and make it go up by the thickness, plus a small margin (0.01 & 0.02 as per below). You don't need hull() here, but note with the commented out cobe() you would need hull() {} i.e. both in curly braces. ---------------------------------- pcb_width=60; pcb_length=88; pcb_thickness=1.8; pcb_height=22; // including the usb ports case_thickness=2; width=pcb_width+case_thickness*2; length=pcb_length+case_thickness; height=pcb_height+case_thickness*2; echo(width=width,length=length,height=height); module case() { // body translate([-width/2,-length/2,0]) difference() { cube([width,length,height]); translate([case_thickness,-0.01,case_thickness]) cube([pcb_width,pcb_length,pcb_height]); // translate([15,15,height-2.2]) //hull() translate([width/2,length/2,height-case_thickness-0.01]) // <==== #cylinder(h = case_thickness+0.02, // <==== r = pcb_width/2-1, center=false, // <==== $fn=60); // cube([30,60,4.5]); } } case(); > -----Original Message----- > From: Robert Brown [mailto:rebrown@exemail.com.au] > Sent: Mon, 18 Jul 2022 14:17 > To: discuss@lists.openscad.org > Subject: [OpenSCAD] Cylinder difference not working > > Hi > > > Thanks for the support forum/mailing list. > > I have a problem getting a difference function to work with a translated > cylinder in that it does not do the expected thing of creating a > cylindrical hole (penetration). It does a partial hole depending upon > the translate z-axis height but no combination of cylinder height of > translate height yields the expected result. Seems I am not > understanding something about the interaction. Tried using hull() and I > also find the cube() will "difference" as expected. > > Thanks for any pointers. > > pcb_width=60; > pcb_length=88; > pcb_thickness=1.8; > pcb_height=22; // including the usb ports > case_thickness=2; > width=pcb_width+case_thickness*2; > length=pcb_length+case_thickness; > height=pcb_height+case_thickness*2; > module case() { > // body > translate([-width/2,-length/2,0]) > difference() { > cube([width,length,height]); > translate([case_thickness,-0.01,case_thickness]) > cube([pcb_width,pcb_length,pcb_height]); > // translate([15,15,height-2.2]) > hull() > translate([width/2,length/2,25.01]) > cylinder(h = 8, r = pcb_width/2-1, true,$fn=60); > // cube([30,60,4.5]); > } > } > > case(); > > Cheers > > Rob B > > -- > Zero emissions by 2050 for a safe climate future. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG. https://www.avg.com
MM
Michael Marx
Mon, Jul 18, 2022 4:40 AM

p.s. and the '#' modifier helps when you're not sure where something is positioned.

-----Original Message-----
From: Michael Marx [mailto:michael@marx.id.au]
Sent: Mon, 18 Jul 2022 14:38
To: 'OpenSCAD general discussion'
Subject: [OpenSCAD] Re: Cylinder difference not working

You need named parameters for center in the cylinder() because of the r v,s r1,r2 options.
You have a choice, either position it centered and use center=true so it grows up/down
equally to cut.
Or position it just below and make it go up by the thickness, plus a small margin (0.01 &
0.02 as per below).
You don't need hull() here,
but note with the commented out cobe() you would need
hull() {} i.e. both in curly braces.


pcb_width=60;
pcb_length=88;
pcb_thickness=1.8;
pcb_height=22; // including the usb ports
case_thickness=2;
width=pcb_width+case_thickness2;
length=pcb_length+case_thickness;
height=pcb_height+case_thickness
2;
echo(width=width,length=length,height=height);
module case() {
// body
translate([-width/2,-length/2,0])
difference() {
cube([width,length,height]);
translate([case_thickness,-0.01,case_thickness])
cube([pcb_width,pcb_length,pcb_height]);
//            translate([15,15,height-2.2])
//hull()
translate([width/2,length/2,height-case_thickness-0.01]) // <====
#cylinder(h = case_thickness+0.02,                  // <====
r = pcb_width/2-1,
center=false,                              // <====
$fn=60);
//                cube([30,60,4.5]);
}
}
case();

-----Original Message-----
From: Robert Brown [mailto:rebrown@exemail.com.au]
Sent: Mon, 18 Jul 2022 14:17
To: discuss@lists.openscad.org
Subject: [OpenSCAD] Cylinder difference not working

Hi

Thanks for the support forum/mailing list.

I have a problem getting a difference function to work with a translated
cylinder in that it does not do the expected thing of creating a
cylindrical hole (penetration). It does a partial hole depending upon
the translate z-axis height but no combination of cylinder height of
translate height yields the expected result. Seems I am not
understanding something about the interaction. Tried using hull() and I
also find the cube() will "difference" as expected.

Thanks for any pointers.

pcb_width=60;
pcb_length=88;
pcb_thickness=1.8;
pcb_height=22; // including the usb ports
case_thickness=2;
width=pcb_width+case_thickness2;
length=pcb_length+case_thickness;
height=pcb_height+case_thickness
2;
module case() {
// body
translate([-width/2,-length/2,0])
difference() {
cube([width,length,height]);
translate([case_thickness,-0.01,case_thickness])
cube([pcb_width,pcb_length,pcb_height]);
//            translate([15,15,height-2.2])
hull()
translate([width/2,length/2,25.01])
cylinder(h = 8, r = pcb_width/2-1, true,$fn=60);
//                cube([30,60,4.5]);
}
}

case();

Cheers

Rob B

--
Zero emissions by 2050 for a safe climate future.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG.
https://www.avg.com


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG.
https://www.avg.com

p.s. and the '#' modifier helps when you're not sure where something is positioned. > -----Original Message----- > From: Michael Marx [mailto:michael@marx.id.au] > Sent: Mon, 18 Jul 2022 14:38 > To: 'OpenSCAD general discussion' > Subject: [OpenSCAD] Re: Cylinder difference not working > > You need named parameters for center in the cylinder() because of the r v,s r1,r2 options. > You have a choice, either position it centered and use center=true so it grows up/down > equally to cut. > Or position it just below and make it go up by the thickness, plus a small margin (0.01 & > 0.02 as per below). > You don't need hull() here, > but note with the commented out cobe() you would need > hull() {} i.e. both in curly braces. > > ---------------------------------- > > pcb_width=60; > pcb_length=88; > pcb_thickness=1.8; > pcb_height=22; // including the usb ports > case_thickness=2; > width=pcb_width+case_thickness*2; > length=pcb_length+case_thickness; > height=pcb_height+case_thickness*2; > echo(width=width,length=length,height=height); > module case() { > // body > translate([-width/2,-length/2,0]) > difference() { > cube([width,length,height]); > translate([case_thickness,-0.01,case_thickness]) > cube([pcb_width,pcb_length,pcb_height]); > // translate([15,15,height-2.2]) > //hull() > translate([width/2,length/2,height-case_thickness-0.01]) // <==== > #cylinder(h = case_thickness+0.02, // <==== > r = pcb_width/2-1, > center=false, // <==== > $fn=60); > // cube([30,60,4.5]); > } > } > case(); > > > > > > -----Original Message----- > > From: Robert Brown [mailto:rebrown@exemail.com.au] > > Sent: Mon, 18 Jul 2022 14:17 > > To: discuss@lists.openscad.org > > Subject: [OpenSCAD] Cylinder difference not working > > > > Hi > > > > > > Thanks for the support forum/mailing list. > > > > I have a problem getting a difference function to work with a translated > > cylinder in that it does not do the expected thing of creating a > > cylindrical hole (penetration). It does a partial hole depending upon > > the translate z-axis height but no combination of cylinder height of > > translate height yields the expected result. Seems I am not > > understanding something about the interaction. Tried using hull() and I > > also find the cube() will "difference" as expected. > > > > Thanks for any pointers. > > > > pcb_width=60; > > pcb_length=88; > > pcb_thickness=1.8; > > pcb_height=22; // including the usb ports > > case_thickness=2; > > width=pcb_width+case_thickness*2; > > length=pcb_length+case_thickness; > > height=pcb_height+case_thickness*2; > > module case() { > > // body > > translate([-width/2,-length/2,0]) > > difference() { > > cube([width,length,height]); > > translate([case_thickness,-0.01,case_thickness]) > > cube([pcb_width,pcb_length,pcb_height]); > > // translate([15,15,height-2.2]) > > hull() > > translate([width/2,length/2,25.01]) > > cylinder(h = 8, r = pcb_width/2-1, true,$fn=60); > > // cube([30,60,4.5]); > > } > > } > > > > case(); > > > > Cheers > > > > Rob B > > > > -- > > Zero emissions by 2050 for a safe climate future. > > _______________________________________________ > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > -- > This email has been checked for viruses by AVG. > https://www.avg.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG. https://www.avg.com
RB
Robert Brown
Mon, Jul 18, 2022 4:53 AM

Thanks Michael.

I had used numerals to troubleshoot as I was getting some odd results.
Works now and thanks for the tips.

Cheers

On 18/7/22 14:37, Michael Marx wrote:

You need named parameters for center in the cylinder() because of the r v,s r1,r2 options.
You have a choice, either position it centered and use center=true so it grows up/down equally to cut.
Or position it just below and make it go up by the thickness, plus a small margin (0.01 & 0.02 as per below).
You don't need hull() here,
but note with the commented out cobe() you would need
hull() {} i.e. both in curly braces.


pcb_width=60;
pcb_length=88;
pcb_thickness=1.8;
pcb_height=22; // including the usb ports
case_thickness=2;
width=pcb_width+case_thickness2;
length=pcb_length+case_thickness;
height=pcb_height+case_thickness
2;
echo(width=width,length=length,height=height);
module case() {
// body
translate([-width/2,-length/2,0])
difference() {
cube([width,length,height]);
translate([case_thickness,-0.01,case_thickness])
cube([pcb_width,pcb_length,pcb_height]);
//            translate([15,15,height-2.2])
//hull()
translate([width/2,length/2,height-case_thickness-0.01]) // <====
#cylinder(h = case_thickness+0.02,                  // <====
r = pcb_width/2-1,
center=false,                              // <====
$fn=60);
//                cube([30,60,4.5]);
}
}
case();

-----Original Message-----
From: Robert Brown [mailto:rebrown@exemail.com.au]
Sent: Mon, 18 Jul 2022 14:17
To: discuss@lists.openscad.org
Subject: [OpenSCAD] Cylinder difference not working

Hi

Thanks for the support forum/mailing list.

I have a problem getting a difference function to work with a translated
cylinder in that it does not do the expected thing of creating a
cylindrical hole (penetration). It does a partial hole depending upon
the translate z-axis height but no combination of cylinder height of
translate height yields the expected result. Seems I am not
understanding something about the interaction. Tried using hull() and I
also find the cube() will "difference" as expected.

Thanks for any pointers.

pcb_width=60;
pcb_length=88;
pcb_thickness=1.8;
pcb_height=22; // including the usb ports
case_thickness=2;
width=pcb_width+case_thickness2;
length=pcb_length+case_thickness;
height=pcb_height+case_thickness
2;
module case() {
// body
translate([-width/2,-length/2,0])
difference() {
cube([width,length,height]);
translate([case_thickness,-0.01,case_thickness])
cube([pcb_width,pcb_length,pcb_height]);
//            translate([15,15,height-2.2])
hull()
translate([width/2,length/2,25.01])
cylinder(h = 8, r = pcb_width/2-1, true,$fn=60);
//                cube([30,60,4.5]);
}
}

case();

Cheers

Rob B

--
Zero emissions by 2050 for a safe climate future.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
Zero emissions by 2050 for a safe climate future.

Thanks Michael. I had used numerals to troubleshoot as I was getting some odd results. Works now and thanks for the tips. Cheers On 18/7/22 14:37, Michael Marx wrote: > You need named parameters for center in the cylinder() because of the r v,s r1,r2 options. > You have a choice, either position it centered and use center=true so it grows up/down equally to cut. > Or position it just below and make it go up by the thickness, plus a small margin (0.01 & 0.02 as per below). > You don't need hull() here, > but note with the commented out cobe() you would need > hull() {} i.e. both in curly braces. > > ---------------------------------- > > pcb_width=60; > pcb_length=88; > pcb_thickness=1.8; > pcb_height=22; // including the usb ports > case_thickness=2; > width=pcb_width+case_thickness*2; > length=pcb_length+case_thickness; > height=pcb_height+case_thickness*2; > echo(width=width,length=length,height=height); > module case() { > // body > translate([-width/2,-length/2,0]) > difference() { > cube([width,length,height]); > translate([case_thickness,-0.01,case_thickness]) > cube([pcb_width,pcb_length,pcb_height]); > // translate([15,15,height-2.2]) > //hull() > translate([width/2,length/2,height-case_thickness-0.01]) // <==== > #cylinder(h = case_thickness+0.02, // <==== > r = pcb_width/2-1, > center=false, // <==== > $fn=60); > // cube([30,60,4.5]); > } > } > case(); > > > > >> -----Original Message----- >> From: Robert Brown [mailto:rebrown@exemail.com.au] >> Sent: Mon, 18 Jul 2022 14:17 >> To: discuss@lists.openscad.org >> Subject: [OpenSCAD] Cylinder difference not working >> >> Hi >> >> >> Thanks for the support forum/mailing list. >> >> I have a problem getting a difference function to work with a translated >> cylinder in that it does not do the expected thing of creating a >> cylindrical hole (penetration). It does a partial hole depending upon >> the translate z-axis height but no combination of cylinder height of >> translate height yields the expected result. Seems I am not >> understanding something about the interaction. Tried using hull() and I >> also find the cube() will "difference" as expected. >> >> Thanks for any pointers. >> >> pcb_width=60; >> pcb_length=88; >> pcb_thickness=1.8; >> pcb_height=22; // including the usb ports >> case_thickness=2; >> width=pcb_width+case_thickness*2; >> length=pcb_length+case_thickness; >> height=pcb_height+case_thickness*2; >> module case() { >> // body >> translate([-width/2,-length/2,0]) >> difference() { >> cube([width,length,height]); >> translate([case_thickness,-0.01,case_thickness]) >> cube([pcb_width,pcb_length,pcb_height]); >> // translate([15,15,height-2.2]) >> hull() >> translate([width/2,length/2,25.01]) >> cylinder(h = 8, r = pcb_width/2-1, true,$fn=60); >> // cube([30,60,4.5]); >> } >> } >> >> case(); >> >> Cheers >> >> Rob B >> >> -- >> Zero emissions by 2050 for a safe climate future. >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > -- Zero emissions by 2050 for a safe climate future.