discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Cap with a hole

FH
Father Horton
Tue, Feb 14, 2023 3:36 AM

It's getting late and I'm probably missing something obvious. I want two
almost identical cylindrical caps; the only difference is that one has a
hole in the middle. So I can do this:

module cap(hole = false) {
if (hole) {
difference() {
cylinder(h = 4, r = 50);
cylinder(h = 4, r = 4); // fix z-fighting later
};
}
else
cylinder(h = t4, r = 50);
};

But repeating the cylinder statement looks really ugly.

What should I be doing?

It's getting late and I'm probably missing something obvious. I want two almost identical cylindrical caps; the only difference is that one has a hole in the middle. So I can do this: module cap(hole = false) { if (hole) { difference() { cylinder(h = 4, r = 50); cylinder(h = 4, r = 4); // fix z-fighting later }; } else cylinder(h = t4, r = 50); }; But repeating the cylinder statement looks really ugly. What should I be doing?
FH
Father Horton
Tue, Feb 14, 2023 3:39 AM

Oops. h = t4 is a typo. It should be h = 4.

On Mon, Feb 13, 2023 at 9:36 PM Father Horton fatherhorton@gmail.com
wrote:

It's getting late and I'm probably missing something obvious. I want two
almost identical cylindrical caps; the only difference is that one has a
hole in the middle. So I can do this:

module cap(hole = false) {
if (hole) {
difference() {
cylinder(h = 4, r = 50);
cylinder(h = 4, r = 4); // fix z-fighting later
};
}
else
cylinder(h = t4, r = 50);
};

But repeating the cylinder statement looks really ugly.

What should I be doing?

Oops. h = t4 is a typo. It should be h = 4. On Mon, Feb 13, 2023 at 9:36 PM Father Horton <fatherhorton@gmail.com> wrote: > It's getting late and I'm probably missing something obvious. I want two > almost identical cylindrical caps; the only difference is that one has a > hole in the middle. So I can do this: > > module cap(hole = false) { > if (hole) { > difference() { > cylinder(h = 4, r = 50); > cylinder(h = 4, r = 4); // fix z-fighting later > }; > } > else > cylinder(h = t4, r = 50); > }; > > But repeating the cylinder statement looks really ugly. > > What should I be doing? >
AM
Adrian Mariano
Tue, Feb 14, 2023 3:45 AM

module cap(hole = false) {
difference() {
cylinder(h = 4, r = 50);
if (hole) cylinder(h = 4, r = 4); // fix z-fighting later
};
};

On Mon, Feb 13, 2023 at 10:40 PM Father Horton fatherhorton@gmail.com
wrote:

Oops. h = t4 is a typo. It should be h = 4.

On Mon, Feb 13, 2023 at 9:36 PM Father Horton fatherhorton@gmail.com
wrote:

It's getting late and I'm probably missing something obvious. I want two
almost identical cylindrical caps; the only difference is that one has a
hole in the middle. So I can do this:

module cap(hole = false) {
if (hole) {
difference() {
cylinder(h = 4, r = 50);
cylinder(h = 4, r = 4); // fix z-fighting later
};
}
else
cylinder(h = t4, r = 50);
};

But repeating the cylinder statement looks really ugly.

What should I be doing?


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

module cap(hole = false) { difference() { cylinder(h = 4, r = 50); if (hole) cylinder(h = 4, r = 4); // fix z-fighting later }; }; On Mon, Feb 13, 2023 at 10:40 PM Father Horton <fatherhorton@gmail.com> wrote: > Oops. h = t4 is a typo. It should be h = 4. > > On Mon, Feb 13, 2023 at 9:36 PM Father Horton <fatherhorton@gmail.com> > wrote: > >> It's getting late and I'm probably missing something obvious. I want two >> almost identical cylindrical caps; the only difference is that one has a >> hole in the middle. So I can do this: >> >> module cap(hole = false) { >> if (hole) { >> difference() { >> cylinder(h = 4, r = 50); >> cylinder(h = 4, r = 4); // fix z-fighting later >> }; >> } >> else >> cylinder(h = t4, r = 50); >> }; >> >> But repeating the cylinder statement looks really ugly. >> >> What should I be doing? >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
FH
Father Horton
Tue, Feb 14, 2023 3:53 AM

Like I said, obvious. Thanks!

On Mon, Feb 13, 2023 at 9:45 PM Adrian Mariano avm4@cornell.edu wrote:

module cap(hole = false) {
difference() {
cylinder(h = 4, r = 50);
if (hole) cylinder(h = 4, r = 4); // fix z-fighting later
};
};

On Mon, Feb 13, 2023 at 10:40 PM Father Horton fatherhorton@gmail.com
wrote:

Oops. h = t4 is a typo. It should be h = 4.

On Mon, Feb 13, 2023 at 9:36 PM Father Horton fatherhorton@gmail.com
wrote:

It's getting late and I'm probably missing something obvious. I want two
almost identical cylindrical caps; the only difference is that one has a
hole in the middle. So I can do this:

module cap(hole = false) {
if (hole) {
difference() {
cylinder(h = 4, r = 50);
cylinder(h = 4, r = 4); // fix z-fighting later
};
}
else
cylinder(h = t4, r = 50);
};

But repeating the cylinder statement looks really ugly.

What should I be doing?


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


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

Like I said, obvious. Thanks! On Mon, Feb 13, 2023 at 9:45 PM Adrian Mariano <avm4@cornell.edu> wrote: > module cap(hole = false) { > difference() { > cylinder(h = 4, r = 50); > if (hole) cylinder(h = 4, r = 4); // fix z-fighting later > }; > }; > > > > On Mon, Feb 13, 2023 at 10:40 PM Father Horton <fatherhorton@gmail.com> > wrote: > >> Oops. h = t4 is a typo. It should be h = 4. >> >> On Mon, Feb 13, 2023 at 9:36 PM Father Horton <fatherhorton@gmail.com> >> wrote: >> >>> It's getting late and I'm probably missing something obvious. I want two >>> almost identical cylindrical caps; the only difference is that one has a >>> hole in the middle. So I can do this: >>> >>> module cap(hole = false) { >>> if (hole) { >>> difference() { >>> cylinder(h = 4, r = 50); >>> cylinder(h = 4, r = 4); // fix z-fighting later >>> }; >>> } >>> else >>> cylinder(h = t4, r = 50); >>> }; >>> >>> But repeating the cylinder statement looks really ugly. >>> >>> What should I be doing? >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
K
Ken
Tue, Feb 14, 2023 3:57 AM

module cap(hole) {
        difference() {
            cylinder(h = 4, r = 50);
            if (hole) cylinder(h = 4, r = 4); // fix z-fighting later
        };
};
cap(hole = true);
translate([0,0,20])
cap(hole = false);

On 2023-02-14 14:53, Father Horton wrote:

Like I said, obvious. Thanks!

On Mon, Feb 13, 2023 at 9:45 PM Adrian Mariano avm4@cornell.edu wrote:

   module cap(hole = false) {
         difference() {
             cylinder(h = 4, r = 50);
             if (hole) cylinder(h = 4, r = 4); // fix z-fighting later
         };
 };



 On Mon, Feb 13, 2023 at 10:40 PM Father Horton
 <fatherhorton@gmail.com> wrote:

     Oops. h = t4 is a typo. It should be h = 4.

     On Mon, Feb 13, 2023 at 9:36 PM Father Horton
     <fatherhorton@gmail.com> wrote:

         It's getting late and I'm probably missing something
         obvious. I want two almost identical cylindrical caps; the
         only difference is that one has a hole in the middle. So I
         can do this:

         module cap(hole = false) {
             if (hole) {
                 difference() {
                     cylinder(h = 4, r = 50);
                     cylinder(h = 4, r = 4); // fix z-fighting later
                 };
             }
             else
                 cylinder(h = t4, r = 50);
         };

         But repeating the cylinder statement looks really ugly.

         What should I be doing?

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

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

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

--
Cheers, Ken
bats059@gmail.com
https://vk7krj.com/running.html
https://sstv.vk7krj.com/all_bands.html

A baby can be defined as an ego with a noise at one end and a smell at the other.
Our job as parents is to teach them to control all three.

module cap(hole) {         difference() {             cylinder(h = 4, r = 50);             if (hole) cylinder(h = 4, r = 4); // fix z-fighting later         }; }; cap(hole = true); translate([0,0,20]) cap(hole = false); On 2023-02-14 14:53, Father Horton wrote: > Like I said, obvious. Thanks! > > On Mon, Feb 13, 2023 at 9:45 PM Adrian Mariano <avm4@cornell.edu> wrote: > >   module cap(hole = false) { >         difference() { >             cylinder(h = 4, r = 50); >             if (hole) cylinder(h = 4, r = 4); // fix z-fighting later >         }; > }; > > > > On Mon, Feb 13, 2023 at 10:40 PM Father Horton > <fatherhorton@gmail.com> wrote: > > Oops. h = t4 is a typo. It should be h = 4. > > On Mon, Feb 13, 2023 at 9:36 PM Father Horton > <fatherhorton@gmail.com> wrote: > > It's getting late and I'm probably missing something > obvious. I want two almost identical cylindrical caps; the > only difference is that one has a hole in the middle. So I > can do this: > > module cap(hole = false) { >     if (hole) { >         difference() { >             cylinder(h = 4, r = 50); >             cylinder(h = 4, r = 4); // fix z-fighting later >         }; >     } >     else >         cylinder(h = t4, r = 50); > }; > > But repeating the cylinder statement looks really ugly. > > What should I be doing? > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org -- Cheers, Ken bats059@gmail.com https://vk7krj.com/running.html https://sstv.vk7krj.com/all_bands.html ---------------------------------------- A baby can be defined as an ego with a noise at one end and a smell at the other. Our job as parents is to teach them to control all three.