discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

nested difference to subtract from solid

H
Hendrik
Fri, Mar 4, 2022 3:29 PM
<!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:11.0pt; font-family:"Calibri",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} .MsoChpDefault {mso-style-type:export-only;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt;} div.WordSection1 {page:WordSection1;} -->Hi

Can anyone tell me rather then building a long cylinder with different diameters and stacking them on top of each other if a person can do rather create a long cylinder and use nested difference() to keep the cylinder solid and only take away the different diameters. For example.

difference() {

cylinder(d=22, h=40, $fn=100);

difference() {

cylinder(d=22, h=2, $fn=100);

cylinder(d=8, h=4, $fn=100);

}

difference() {

translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

}

difference() {

translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

}

difference() {

translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

}

difference() {

translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

}

translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

Sent from Mail for Windows

MM
Michael Möller
Fri, Mar 4, 2022 3:47 PM

If I understand your question correctly, you pose a possible construction
technique, give an example, and ask if it works.

What happens when you run that code?

(Yeah, I tried your example, it has a simple typo, and in preview you get
Z-fighting, which is easily fixable by making the subtraction cylinders
slightly larger)

Or are you asking something else?

Michael, fra mobilen

fre. 4. mar. 2022 16.30 skrev Hendrik blindguydiy@gmail.com:

Hi

Can anyone tell me rather then building a long cylinder with different
diameters and stacking them on top of each other if a person can do rather
create a long cylinder and use nested difference() to keep the cylinder
solid and only take away the different diameters.  For example.

difference() {

 cylinder(d=22, h=40, $fn=100);

 difference() {

     cylinder(d=22, h=2, $fn=100);

     cylinder(d=8, h=4, $fn=100);

 }

 difference() {

     translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

     translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

 }

 difference() {

     translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

     translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

 }

 difference() {

     translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

     translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

 }

 difference() {

     translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

     translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

 }

 translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for
Windows


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

If I understand your question correctly, you pose a possible construction technique, give an example, and ask if it works. What happens when *you* run that code? (Yeah, I tried your example, it has a simple typo, and in preview you get Z-fighting, which is easily fixable by making the subtraction cylinders slightly larger) Or are you asking something else? Michael, fra mobilen fre. 4. mar. 2022 16.30 skrev Hendrik <blindguydiy@gmail.com>: > Hi > > > > Can anyone tell me rather then building a long cylinder with different > diameters and stacking them on top of each other if a person can do rather > create a long cylinder and use nested difference() to keep the cylinder > solid and only take away the different diameters. For example. > > > > difference() { > > cylinder(d=22, h=40, $fn=100); > > difference() { > > cylinder(d=22, h=2, $fn=100); > > cylinder(d=8, h=4, $fn=100); > > } > > difference() { > > translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100); > > translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100); > > } > > difference() { > > translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100); > > translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100); > > } > > difference() { > > translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100); > > translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100); > > } > > difference() { > > translate([0,0,12]) cylinder(d=22, h=28, $fn=100); > > translate([0,0,11]) cylinder(d=16, h=30, $fn=100); > > } > > translate([0,0,15]) cylinder(d=12, 26, $fn=100);); > > } > > > > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for > Windows > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
J
jon
Fri, Mar 4, 2022 3:47 PM

You could build the profile in 2D and then rotate_extrude() it.

Jon

On 3/4/2022 10:29 AM, Hendrik wrote:

difference() {

    cylinder(d=22, h=40, $fn=100);

    difference() {

        cylinder(d=22, h=2, $fn=100);

        cylinder(d=8, h=4, $fn=100);

    }

    difference() {

        translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

        translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

    }

    difference() {

translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

    }

    difference() {

translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

    }

    difference() {

translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

    }

    translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

You could build the profile in 2D and then rotate_extrude() it. Jon On 3/4/2022 10:29 AM, Hendrik wrote: > > difference() { > >     cylinder(d=22, h=40, $fn=100); > >     difference() { > >         cylinder(d=22, h=2, $fn=100); > >         cylinder(d=8, h=4, $fn=100); > >     } > >     difference() { > >         translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100); > >         translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100); > >     } > >     difference() { > > translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100); > > translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100); > >     } > >     difference() { > > translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100); > > translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100); > >     } > >     difference() { > > translate([0,0,12]) cylinder(d=22, h=28, $fn=100); > > translate([0,0,11]) cylinder(d=16, h=30, $fn=100); > >     } > >     translate([0,0,15]) cylinder(d=12, 26, $fn=100);); > > } >
NH
nop head
Fri, Mar 4, 2022 4:02 PM

Another way to make it that would execute much faster is to
rotate_extrude() a half profile, which would either be a polygon or a union
of squares.

On Fri, 4 Mar 2022 at 15:48, Michael Möller private2michael@gmail.com
wrote:

If I understand your question correctly, you pose a possible construction
technique, give an example, and ask if it works.

What happens when you run that code?

(Yeah, I tried your example, it has a simple typo, and in preview you get
Z-fighting, which is easily fixable by making the subtraction cylinders
slightly larger)

Or are you asking something else?

Michael, fra mobilen

fre. 4. mar. 2022 16.30 skrev Hendrik blindguydiy@gmail.com:

Hi

Can anyone tell me rather then building a long cylinder with different
diameters and stacking them on top of each other if a person can do rather
create a long cylinder and use nested difference() to keep the cylinder
solid and only take away the different diameters.  For example.

difference() {

 cylinder(d=22, h=40, $fn=100);

 difference() {

     cylinder(d=22, h=2, $fn=100);

     cylinder(d=8, h=4, $fn=100);

 }

 difference() {

     translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

     translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

 }

 difference() {

     translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

     translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

 }

 difference() {

     translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

     translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

 }

 difference() {

     translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

     translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

 }

 translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for
Windows


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

Another way to make it that would execute much faster is to rotate_extrude() a half profile, which would either be a polygon or a union of squares. On Fri, 4 Mar 2022 at 15:48, Michael Möller <private2michael@gmail.com> wrote: > If I understand your question correctly, you pose a possible construction > technique, give an example, and ask if it works. > > What happens when *you* run that code? > > (Yeah, I tried your example, it has a simple typo, and in preview you get > Z-fighting, which is easily fixable by making the subtraction cylinders > slightly larger) > > Or are you asking something else? > > Michael, fra mobilen > > fre. 4. mar. 2022 16.30 skrev Hendrik <blindguydiy@gmail.com>: > >> Hi >> >> >> >> Can anyone tell me rather then building a long cylinder with different >> diameters and stacking them on top of each other if a person can do rather >> create a long cylinder and use nested difference() to keep the cylinder >> solid and only take away the different diameters. For example. >> >> >> >> difference() { >> >> cylinder(d=22, h=40, $fn=100); >> >> difference() { >> >> cylinder(d=22, h=2, $fn=100); >> >> cylinder(d=8, h=4, $fn=100); >> >> } >> >> difference() { >> >> translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100); >> >> translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100); >> >> } >> >> difference() { >> >> translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100); >> >> translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100); >> >> } >> >> difference() { >> >> translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100); >> >> translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100); >> >> } >> >> difference() { >> >> translate([0,0,12]) cylinder(d=22, h=28, $fn=100); >> >> translate([0,0,11]) cylinder(d=16, h=30, $fn=100); >> >> } >> >> translate([0,0,15]) cylinder(d=12, 26, $fn=100);); >> >> } >> >> >> >> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for >> Windows >> >> >> _______________________________________________ >> 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 >
H
Hendrik
Fri, Mar 4, 2022 4:20 PM
<!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:11.0pt; font-family:"Calibri",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} .MsoChpDefault {mso-style-type:export-only;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt;} div.WordSection1 {page:WordSection1;} -->Well first because I am so new not sure yet about the extrusion and also do not know with extrusion if I need to see the screen for I am blind.

If I run the code with f5 and f6 I get no errors and it loads it. But will have to try and find someone to see what is on the screen..

I can even export it.

Sent from Mail for Windows

From: Michael Möller
Sent: Friday, 04 March 2022 17:48
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: nested difference to subtract from solid

If I understand your question correctly, you pose a possible construction technique, give an example, and ask if it works.

What happens when *you* run that code?

(Yeah, I tried your example, it has a simple typo, and in preview you get Z-fighting, which is easily fixable by making the subtraction cylinders slightly larger)

Or are you asking something else?

Michael, fra mobilen

fre. 4. mar. 2022 16.30 skrev Hendrik <blindguydiy@gmail.com>:

Hi

Can anyone tell me rather then building a long cylinder with different diameters and stacking them on top of each other if a person can do rather create a long cylinder and use nested difference() to keep the cylinder solid and only take away the different diameters. For example.

difference() {

cylinder(d=22, h=40, $fn=100);

difference() {

cylinder(d=22, h=2, $fn=100);

cylinder(d=8, h=4, $fn=100);

}

difference() {

translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

}

difference() {

translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

}

difference() {

translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

}

difference() {

translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

}

translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

Sent from Mail for Windows

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

H
Hendrik
Fri, Mar 4, 2022 4:25 PM
<!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:11.0pt; font-family:"Calibri",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} .MsoChpDefault {mso-style-type:export-only;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt;} div.WordSection1 {page:WordSection1;} -->The reason why I looked at doing it that way, it means that it is one solid part and problems with correctly union where small spaces can appear is excluded. So just was wondering if it could be done like that. On the other hand say I stack all the different cylinders is it safer to include a esp=0.01 or something like that to make sure no spaces appear. Could it do any harm in including the esp or could it be just a safety net.

Sent from Mail for Windows

From: Michael Möller
Sent: Friday, 04 March 2022 17:48
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: nested difference to subtract from solid

If I understand your question correctly, you pose a possible construction technique, give an example, and ask if it works.

What happens when *you* run that code?

(Yeah, I tried your example, it has a simple typo, and in preview you get Z-fighting, which is easily fixable by making the subtraction cylinders slightly larger)

Or are you asking something else?

Michael, fra mobilen

fre. 4. mar. 2022 16.30 skrev Hendrik <blindguydiy@gmail.com>:

Hi

Can anyone tell me rather then building a long cylinder with different diameters and stacking them on top of each other if a person can do rather create a long cylinder and use nested difference() to keep the cylinder solid and only take away the different diameters. For example.

difference() {

cylinder(d=22, h=40, $fn=100);

difference() {

cylinder(d=22, h=2, $fn=100);

cylinder(d=8, h=4, $fn=100);

}

difference() {

translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

}

difference() {

translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

}

difference() {

translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

}

difference() {

translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

}

translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

Sent from Mail for Windows

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

NH
nop head
Fri, Mar 4, 2022 4:59 PM

In general it is wise to overlap unioned shapes, especially in 3D. In your
case all the heights look like they can be represented exactly in floating
point fractions, so you probably get away without it.

On Fri, 4 Mar 2022 at 16:26, Hendrik blindguydiy@gmail.com wrote:

The reason why I looked at doing it that way, it means that it is one
solid part and problems with correctly union where small spaces can appear
is excluded.  So just was wondering if it could be done like that.  On the
other hand say I stack all the different cylinders is it safer to include a
esp=0.01 or something like that to make sure no spaces appear.  Could it do
any harm in including the esp or could it be just a safety net.

Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for
Windows

*From: *Michael Möller private2michael@gmail.com
*Sent: *Friday, 04 March 2022 17:48
*To: *OpenSCAD general discussion discuss@lists.openscad.org
*Subject: *[OpenSCAD] Re: nested difference to subtract from solid

If I understand your question correctly, you pose a possible construction
technique, give an example, and ask if it works.

What happens when you run that code?

(Yeah, I tried your example, it has a simple typo, and in preview you get
Z-fighting, which is easily fixable by making the subtraction cylinders
slightly larger)

Or are you asking something else?

Michael, fra mobilen

fre. 4. mar. 2022 16.30 skrev Hendrik blindguydiy@gmail.com:

Hi

Can anyone tell me rather then building a long cylinder with different
diameters and stacking them on top of each other if a person can do rather
create a long cylinder and use nested difference() to keep the cylinder
solid and only take away the different diameters.  For example.

difference() {

 cylinder(d=22, h=40, $fn=100);

 difference() {

     cylinder(d=22, h=2, $fn=100);

     cylinder(d=8, h=4, $fn=100);

 }

 difference() {

     translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

     translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

 }

 difference() {

     translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

     translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

 }

 difference() {

     translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

     translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

 }

 difference() {

     translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

     translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

 }

 translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for
Windows


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

In general it is wise to overlap unioned shapes, especially in 3D. In your case all the heights look like they can be represented exactly in floating point fractions, so you probably get away without it. On Fri, 4 Mar 2022 at 16:26, Hendrik <blindguydiy@gmail.com> wrote: > The reason why I looked at doing it that way, it means that it is one > solid part and problems with correctly union where small spaces can appear > is excluded. So just was wondering if it could be done like that. On the > other hand say I stack all the different cylinders is it safer to include a > esp=0.01 or something like that to make sure no spaces appear. Could it do > any harm in including the esp or could it be just a safety net. > > > > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for > Windows > > > > *From: *Michael Möller <private2michael@gmail.com> > *Sent: *Friday, 04 March 2022 17:48 > *To: *OpenSCAD general discussion <discuss@lists.openscad.org> > *Subject: *[OpenSCAD] Re: nested difference to subtract from solid > > > > If I understand your question correctly, you pose a possible construction > technique, give an example, and ask if it works. > > > > What happens when *you* run that code? > > > > (Yeah, I tried your example, it has a simple typo, and in preview you get > Z-fighting, which is easily fixable by making the subtraction cylinders > slightly larger) > > > > Or are you asking something else? > > > > Michael, fra mobilen > > > > fre. 4. mar. 2022 16.30 skrev Hendrik <blindguydiy@gmail.com>: > > Hi > > > > Can anyone tell me rather then building a long cylinder with different > diameters and stacking them on top of each other if a person can do rather > create a long cylinder and use nested difference() to keep the cylinder > solid and only take away the different diameters. For example. > > > > difference() { > > cylinder(d=22, h=40, $fn=100); > > difference() { > > cylinder(d=22, h=2, $fn=100); > > cylinder(d=8, h=4, $fn=100); > > } > > difference() { > > translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100); > > translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100); > > } > > difference() { > > translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100); > > translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100); > > } > > difference() { > > translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100); > > translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100); > > } > > difference() { > > translate([0,0,12]) cylinder(d=22, h=28, $fn=100); > > translate([0,0,11]) cylinder(d=16, h=30, $fn=100); > > } > > translate([0,0,15]) cylinder(d=12, 26, $fn=100);); > > } > > > > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for > Windows > > > > _______________________________________________ > 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 >
BC
Bob Carter
Fri, Mar 4, 2022 5:35 PM

Hendrik,

nop.head’s alternative is this,

rotate_extrude($fn=100)
polygon(points=
[[0,0],
[4,0],
[4,2],
[3.5,2],
[3.5,3.5],
[4,3.5],
[4,8.5],
[3.5,8.5],
[3.5,10],
[11,10],
[11,12],
[8,12],
[8,40],
[6,40],
[6,12],
[0,12],
[0,0]]
);

Whilst this is simpler to code and execute it may be more difficult for you to visualise.  I think I have the values correct I overlaid the two outputs and they look the same to me.

The polygon is a list of co-ordinates to draw out a flat shape that describes the cross section profile of one half of your finished set of cylinders complete with holes.  This is then rotated about the z axis through 360 to create the finished object.

Note the final [0,0] point is not strictly necessary, it is not shown in the examples, and the code works without it, but I just like to close out shapes..

I use this method to create the various bezel cross section shapes for my dial instruments, I then use translate to push the profile away from the z axis before rotate_extrude to create the hole for the glass to go in the middle.

Cheers
Bob C

On 4 Mar 2022, at 16:59, nop head nop.head@gmail.com wrote:

In general it is wise to overlap unioned shapes, especially in 3D. In your case all the heights look like they can be represented exactly in floating point fractions, so you probably get away without it.

On Fri, 4 Mar 2022 at 16:26, Hendrik <blindguydiy@gmail.com mailto:blindguydiy@gmail.com> wrote:
The reason why I looked at doing it that way, it means that it is one solid part and problems with correctly union where small spaces can appear is excluded.  So just was wondering if it could be done like that.  On the other hand say I stack all the different cylinders is it safer to include a esp=0.01 or something like that to make sure no spaces appear.  Could it do any harm in including the esp or could it be just a safety net.

Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for Windows

From: Michael Möller mailto:private2michael@gmail.com
Sent: Friday, 04 March 2022 17:48
To: OpenSCAD general discussion mailto:discuss@lists.openscad.org
Subject: [OpenSCAD] Re: nested difference to subtract from solid

If I understand your question correctly, you pose a possible construction technique, give an example, and ask if it works.

What happens when you run that code?

(Yeah, I tried your example, it has a simple typo, and in preview you get Z-fighting, which is easily fixable by making the subtraction cylinders slightly larger)

Or are you asking something else?

Michael, fra mobilen

fre. 4. mar. 2022 16.30 skrev Hendrik <blindguydiy@gmail.com mailto:blindguydiy@gmail.com>:

Hi

Can anyone tell me rather then building a long cylinder with different diameters and stacking them on top of each other if a person can do rather create a long cylinder and use nested difference() to keep the cylinder solid and only take away the different diameters.  For example.

difference() {

 cylinder(d=22, h=40, $fn=100);

 difference() {

     cylinder(d=22, h=2, $fn=100);

     cylinder(d=8, h=4, $fn=100);

 }

 difference() {

     translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

     translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

 }

 difference() {

     translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

     translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

 }

 difference() {

     translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

     translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

 }

 difference() {

     translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

     translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

 }

 translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

Sent from Mail https://go.microsoft.com/fwlink/?LinkId=550986 for Windows


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


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


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

Hendrik, nop.head’s alternative is this, rotate_extrude($fn=100) polygon(points= [[0,0], [4,0], [4,2], [3.5,2], [3.5,3.5], [4,3.5], [4,8.5], [3.5,8.5], [3.5,10], [11,10], [11,12], [8,12], [8,40], [6,40], [6,12], [0,12], [0,0]] ); Whilst this is simpler to code and execute it may be more difficult for you to visualise. I think I have the values correct I overlaid the two outputs and they look the same to me. The polygon is a list of co-ordinates to draw out a flat shape that describes the cross section profile of one half of your finished set of cylinders complete with holes. This is then rotated about the z axis through 360 to create the finished object. Note the final [0,0] point is not strictly necessary, it is not shown in the examples, and the code works without it, but I just like to close out shapes.. I use this method to create the various bezel cross section shapes for my dial instruments, I then use translate to push the profile away from the z axis before rotate_extrude to create the hole for the glass to go in the middle. Cheers Bob C > On 4 Mar 2022, at 16:59, nop head <nop.head@gmail.com> wrote: > > In general it is wise to overlap unioned shapes, especially in 3D. In your case all the heights look like they can be represented exactly in floating point fractions, so you probably get away without it. > > On Fri, 4 Mar 2022 at 16:26, Hendrik <blindguydiy@gmail.com <mailto:blindguydiy@gmail.com>> wrote: > The reason why I looked at doing it that way, it means that it is one solid part and problems with correctly union where small spaces can appear is excluded. So just was wondering if it could be done like that. On the other hand say I stack all the different cylinders is it safer to include a esp=0.01 or something like that to make sure no spaces appear. Could it do any harm in including the esp or could it be just a safety net. > > > > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows > > > > From: Michael Möller <mailto:private2michael@gmail.com> > Sent: Friday, 04 March 2022 17:48 > To: OpenSCAD general discussion <mailto:discuss@lists.openscad.org> > Subject: [OpenSCAD] Re: nested difference to subtract from solid > > > > If I understand your question correctly, you pose a possible construction technique, give an example, and ask if it works. > > > > What happens when *you* run that code? > > > > (Yeah, I tried your example, it has a simple typo, and in preview you get Z-fighting, which is easily fixable by making the subtraction cylinders slightly larger) > > > > Or are you asking something else? > > > > Michael, fra mobilen > > > > fre. 4. mar. 2022 16.30 skrev Hendrik <blindguydiy@gmail.com <mailto:blindguydiy@gmail.com>>: > > Hi > > > Can anyone tell me rather then building a long cylinder with different diameters and stacking them on top of each other if a person can do rather create a long cylinder and use nested difference() to keep the cylinder solid and only take away the different diameters. For example. > > > difference() { > > cylinder(d=22, h=40, $fn=100); > > difference() { > > cylinder(d=22, h=2, $fn=100); > > cylinder(d=8, h=4, $fn=100); > > } > > difference() { > > translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100); > > translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100); > > } > > difference() { > > translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100); > > translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100); > > } > > difference() { > > translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100); > > translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100); > > } > > difference() { > > translate([0,0,12]) cylinder(d=22, h=28, $fn=100); > > translate([0,0,11]) cylinder(d=16, h=30, $fn=100); > > } > > translate([0,0,15]) cylinder(d=12, 26, $fn=100);); > > } > > > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
H
Hendrik
Fri, Mar 4, 2022 6:28 PM
<!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:11.0pt; font-family:"Calibri",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} .MsoChpDefault {mso-style-type:export-only;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt;} div.WordSection1 {page:WordSection1;} -->Thanks Bob will check this out but first have to try and see it in my head. But thank you very much

Sent from Mail for Windows

From: Bob Carter
Sent: Friday, 04 March 2022 19:35
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: nested difference to subtract from solid

Hendrik,

nop.head’s alternative is this,

rotate_extrude($fn=100)

polygon(points=

[[0,0],

[4,0],

[4,2],

[3.5,2],

[3.5,3.5],

[4,3.5],

[4,8.5],

[3.5,8.5],

[3.5,10],

[11,10],

[11,12],

[8,12],

[8,40],

[6,40],

[6,12],

[0,12],

[0,0]]

);

Whilst this is simpler to code and execute it may be more difficult for you to visualise. I think I have the values correct I overlaid the two outputs and they look the same to me.

The polygon is a list of co-ordinates to draw out a flat shape that describes the cross section profile of one half of your finished set of cylinders complete with holes. This is then rotated about the z axis through 360 to create the finished object.

Note the final [0,0] point is not strictly necessary, it is not shown in the examples, and the code works without it, but I just like to close out shapes..

I use this method to create the various bezel cross section shapes for my dial instruments, I then use translate to push the profile away from the z axis before rotate_extrude to create the hole for the glass to go in the middle.

Cheers

Bob C

On 4 Mar 2022, at 16:59, nop head <nop.head@gmail.com> wrote:

In general it is wise to overlap unioned shapes, especially in 3D. In your case all the heights look like they can be represented exactly in floating point fractions, so you probably get away without it.

On Fri, 4 Mar 2022 at 16:26, Hendrik <blindguydiy@gmail.com> wrote:

The reason why I looked at doing it that way, it means that it is one solid part and problems with correctly union where small spaces can appear is excluded. So just was wondering if it could be done like that. On the other hand say I stack all the different cylinders is it safer to include a esp=0.01 or something like that to make sure no spaces appear. Could it do any harm in including the esp or could it be just a safety net.

Sent from Mail for Windows

From: Michael Möller
Sent: Friday, 04 March 2022 17:48
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: nested difference to subtract from solid

If I understand your question correctly, you pose a possible construction technique, give an example, and ask if it works.

What happens when *you* run that code?

(Yeah, I tried your example, it has a simple typo, and in preview you get Z-fighting, which is easily fixable by making the subtraction cylinders slightly larger)

Or are you asking something else?

Michael, fra mobilen

fre. 4. mar. 2022 16.30 skrev Hendrik <blindguydiy@gmail.com>:

Hi

Can anyone tell me rather then building a long cylinder with different diameters and stacking them on top of each other if a person can do rather create a long cylinder and use nested difference() to keep the cylinder solid and only take away the different diameters. For example.

difference() {

cylinder(d=22, h=40, $fn=100);

difference() {

cylinder(d=22, h=2, $fn=100);

cylinder(d=8, h=4, $fn=100);

}

difference() {

translate([0,0,2]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,1]) cylinder(d=7, h=3.5, $fn=100);

}

difference() {

translate([0,0,3.5]) cylinder(d=22, h=5, $fn=100);

translate([0,0,2.5]) cylinder(d=8, h=7, $fn=100);

}

difference() {

translate([0,0,8.5]) cylinder(d=22, h=1.5, $fn=100);

translate([0,0,7.5]) cylinder(d=7, h=3.5, $fn=100);

}

difference() {

translate([0,0,12]) cylinder(d=22, h=28, $fn=100);

translate([0,0,11]) cylinder(d=16, h=30, $fn=100);

}

translate([0,0,15]) cylinder(d=12, 26, $fn=100););

}

Sent from Mail for Windows

_______________________________________________
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 to discuss-leave@lists.openscad.org

RW
Rogier Wolff
Sat, Mar 5, 2022 12:14 PM

On Fri, Mar 04, 2022 at 04:59:16PM +0000, nop head wrote:

In general it is wise to overlap unioned shapes, especially in 3D. In your
case all the heights look like they can be represented exactly in floating
point fractions, so you probably get away without it.

In general you don't usually want such "fragile" code. Fragile means
that a "should be independent" change impacts/breaks code you didn't touch.

In this case, moving everything up by say 0.1mm will cause the floating
point representations to be endlessly repeating, the roundoff can then cause
a small gap or an overlap.

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Fri, Mar 04, 2022 at 04:59:16PM +0000, nop head wrote: > In general it is wise to overlap unioned shapes, especially in 3D. In your > case all the heights look like they can be represented exactly in floating > point fractions, so you probably get away without it. In general you don't usually want such "fragile" code. Fragile means that a "should be independent" change impacts/breaks code you didn't touch. In this case, moving everything up by say 0.1mm will cause the floating point representations to be endlessly repeating, the roundoff can then cause a small gap or an overlap. Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.