discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

difference() not working as expected with rotate_extrude()

JW
J.C. Wren
Wed, Mar 21, 2018 2:25 PM

Hello!

I'm a novice OpenSCAD user, but not completely incompetent (or so I like to
think). I'm trying to difference a cube() with a rotate_extrude(), and I
expected the area of the cube within the torus to be differenced out. Am I
understanding something incorrectly here? I've used difference() many times
with cylinders, spheres, and other objects without issue.  Using version
2018.01.06 (git 347eb1) under Windows. This is the code:

sides=360;
holder_width=28;
bolt_dia=16.66;
bolt_h_offset=5;
bolt_v_offset=16;

difference () {
translate ([0, -5.5, 0])
cube ([holder_width, 5.5, bolt_v_offset]);
translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset])
#rotate ([270, 360 - 1, 0])
rotate_extrude (angle=180 + 2, convexity=10, $fn=sides)
translate ([5.55, 0, 0])
circle (d=5.55, $fn=sides);
}

I've increased the angle by 2 degrees and the circle diameter by a fraction
to make sure there's no actual way the area inside the torus can still be
connected to the rest of the piece. I was planning on union()'ing this
piece with another torus of the same size, because obviously the
difference() would leave the torus subtracted. I just hadn't gotten that
far yet because I can't make this work.

The net effect I'm going for is that this piece is a support for a
tailshaft. The tailshaft has a cutout that needs to rest on the inner part
of the torus, but the outside of the torus needs to fully supported to make
it printable. I may (probably!) be doing this the hard way, so I'm open to
better ways to do it.

Thanks!
--jc

Save a life; adopt a shelter animal.

Hello! I'm a novice OpenSCAD user, but not completely incompetent (or so I like to think). I'm trying to difference a cube() with a rotate_extrude(), and I expected the area of the cube within the torus to be differenced out. Am I understanding something incorrectly here? I've used difference() many times with cylinders, spheres, and other objects without issue. Using version 2018.01.06 (git 347eb1) under Windows. This is the code: sides=360; holder_width=28; bolt_dia=16.66; bolt_h_offset=5; bolt_v_offset=16; difference () { translate ([0, -5.5, 0]) cube ([holder_width, 5.5, bolt_v_offset]); translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset]) #rotate ([270, 360 - 1, 0]) rotate_extrude (angle=180 + 2, convexity=10, $fn=sides) translate ([5.55, 0, 0]) circle (d=5.55, $fn=sides); } I've increased the angle by 2 degrees and the circle diameter by a fraction to make sure there's no actual way the area inside the torus can still be connected to the rest of the piece. I was planning on union()'ing this piece with another torus of the same size, because obviously the difference() would leave the torus subtracted. I just hadn't gotten that far yet because I can't make this work. The net effect I'm going for is that this piece is a support for a tailshaft. The tailshaft has a cutout that needs to rest on the inner part of the torus, but the outside of the torus needs to fully supported to make it printable. I may (probably!) be doing this the hard way, so I'm open to better ways to do it. Thanks! --jc Save a life; adopt a shelter animal.
F
fred_dot_u
Wed, Mar 21, 2018 2:52 PM

http://forum.openscad.org/file/t824/cubeminustorus.png

Is this the result you experience, or is this the result you desire to
accomplish?

I did nothing to your code other than to reduce $fn to 60, as 360 means
excessive processing time and doesn't (shouldn't?) affect the final result.

I'm using 2017.1.20 on windows 7, which may be relevant if this is your
objective.

--
Sent from: http://forum.openscad.org/

<http://forum.openscad.org/file/t824/cubeminustorus.png> Is this the result you experience, or is this the result you desire to accomplish? I did nothing to your code other than to reduce $fn to 60, as 360 means excessive processing time and doesn't (shouldn't?) affect the final result. I'm using 2017.1.20 on windows 7, which may be relevant if this is your objective. -- Sent from: http://forum.openscad.org/
JW
J.C. Wren
Wed, Mar 21, 2018 3:03 PM

No, what I want is to keep the yellow and red parts, and remove the blue
parts. Not sure if I'm doing this right to attach an image or not (it's
inlined in the email).

--jc

Save a life; adopt a shelter animal.

On Wed, Mar 21, 2018 at 10:52 AM, fred_dot_u fred_dot_u@yahoo.com wrote:

http://forum.openscad.org/file/t824/cubeminustorus.png

Is this the result you experience, or is this the result you desire to
accomplish?

I did nothing to your code other than to reduce $fn to 60, as 360 means
excessive processing time and doesn't (shouldn't?) affect the final result.

I'm using 2017.1.20 on windows 7, which may be relevant if this is your
objective.

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No, what I want is to keep the yellow and red parts, and remove the blue parts. Not sure if I'm doing this right to attach an image or not (it's inlined in the email). --jc Save a life; adopt a shelter animal. On Wed, Mar 21, 2018 at 10:52 AM, fred_dot_u <fred_dot_u@yahoo.com> wrote: > <http://forum.openscad.org/file/t824/cubeminustorus.png> > > Is this the result you experience, or is this the result you desire to > accomplish? > > I did nothing to your code other than to reduce $fn to 60, as 360 means > excessive processing time and doesn't (shouldn't?) affect the final result. > > I'm using 2017.1.20 on windows 7, which may be relevant if this is your > objective. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
RP
Ronaldo Persiano
Wed, Mar 21, 2018 3:38 PM

As the torus transversal section diameter is greater than the block width,
the difference will produce two separate parts. Is that what you want? If
so, it would be better to generate  separately each part. For 3d printing
purposes, you may use a lower value of $fn with the benefit of a faster
render.

As the torus transversal section diameter is greater than the block width, the difference will produce two separate parts. Is that what you want? If so, it would be better to generate separately each part. For 3d printing purposes, you may use a lower value of $fn with the benefit of a faster render.
RP
Ronaldo Persiano
Wed, Mar 21, 2018 3:42 PM

No, what I want is to keep the yellow and red parts, and remove the blue
parts. Not sure if I'm doing this right to attach an image or not (it's
inlined in the email).

​To get it, difference the hull of the torus from the cube.

sides=60;
holder_width=28;
bolt_dia=16.66;
bolt_h_offset=5;
bolt_v_offset=16;

difference () {
translate ([0, -5.5, 0])
cube ([holder_width, 5.5, bolt_v_offset]);

hull() // <<<<<<<<<<<<<<<

translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset])
#rotate ([270, 360 - 1, 0])
rotate_extrude (convexity=10, $fn=sides)
translate ([5.55, 0, 0])
circle (d=5.55, $fn=sides);
}​

> > > No, what I want is to keep the yellow and red parts, and remove the blue > parts. Not sure if I'm doing this right to attach an image or not (it's > inlined in the email). > > > > > > ​To get it, difference the hull of the torus from the cube. sides=60; holder_width=28; bolt_dia=16.66; bolt_h_offset=5; bolt_v_offset=16; difference () { translate ([0, -5.5, 0]) cube ([holder_width, 5.5, bolt_v_offset]); hull() // <<<<<<<<<<<<<<< translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset]) #rotate ([270, 360 - 1, 0]) rotate_extrude (convexity=10, $fn=sides) translate ([5.55, 0, 0]) circle (d=5.55, $fn=sides); }​
JW
J.C. Wren
Wed, Mar 21, 2018 3:50 PM

The addition of hull() gets much closer to what I want, except I want to
keep the torus itself. From the previous image, I want to keep the yellow
and red sections, and remove the blue.

--jc

Save a life; adopt a shelter animal.

On Wed, Mar 21, 2018 at 11:38 AM, Ronaldo Persiano rcmpersiano@gmail.com
wrote:

As the torus transversal section diameter is greater than the block width,
the difference will produce two separate parts. Is that what you want? If
so, it would be better to generate  separately each part. For 3d printing
purposes, you may use a lower value of $fn with the benefit of a faster
render.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

The addition of hull() gets much closer to what I want, except I want to keep the torus itself. From the previous image, I want to keep the yellow and red sections, and remove the blue. --jc Save a life; adopt a shelter animal. On Wed, Mar 21, 2018 at 11:38 AM, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > As the torus transversal section diameter is greater than the block width, > the difference will produce two separate parts. Is that what you want? If > so, it would be better to generate separately each part. For 3d printing > purposes, you may use a lower value of $fn with the benefit of a faster > render. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
JW
J.C. Wren
Wed, Mar 21, 2018 4:26 PM

This is horribly painful to render with $fn=360 (x seconds on a 6-core 3GHz
AMD), but is the end result I want (I know I can lower that for 3D
printing, of course). But there must be a better way?

sides=360;
holder_width=28;
bolt_dia=16.66;
bolt_h_offset=5;
bolt_v_offset=16;

module torus (fix=0) {
translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset])
rotate ([270, 0, 0])
rotate_extrude (angle=180, convexity=10, $fn=sides)
translate ([5.5 + fix, 0, 0])
circle (d=5.5 + fix, $fn=sides);
}

difference () {
translate ([0, -5.5, 0])
cube ([holder_width, 5.5, bolt_v_offset]);
hull ()
torus ();
}

//
//  Fix required, or complains that it's not manifold.
//
torus (0.01);

//  16 -  1 seconds
//  32 -  4 seconds
//  64 -  12 seconds
// 128 -  42 seconds
// 180 -  81 seconds
// 360 - 308 seconds (LOL, 2GiB memory!)

--jc

Save a life; adopt a shelter animal.

On Wed, Mar 21, 2018 at 11:50 AM, J.C. Wren jcwren@jcwren.com wrote:

The addition of hull() gets much closer to what I want, except I want to
keep the torus itself. From the previous image, I want to keep the yellow
and red sections, and remove the blue.

--jc

Save a life; adopt a shelter animal.

On Wed, Mar 21, 2018 at 11:38 AM, Ronaldo Persiano rcmpersiano@gmail.com
wrote:

As the torus transversal section diameter is greater than the block
width, the difference will produce two separate parts. Is that what you
want? If so, it would be better to generate  separately each part. For
3d printing purposes, you may use a lower value of $fn with the benefit of
a faster render.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

This is horribly painful to render with $fn=360 (x seconds on a 6-core 3GHz AMD), but is the end result I want (I know I can lower that for 3D printing, of course). But there must be a better way? sides=360; holder_width=28; bolt_dia=16.66; bolt_h_offset=5; bolt_v_offset=16; module torus (fix=0) { translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset]) rotate ([270, 0, 0]) rotate_extrude (angle=180, convexity=10, $fn=sides) translate ([5.5 + fix, 0, 0]) circle (d=5.5 + fix, $fn=sides); } difference () { translate ([0, -5.5, 0]) cube ([holder_width, 5.5, bolt_v_offset]); hull () torus (); } // // Fix required, or complains that it's not manifold. // torus (0.01); // 16 - 1 seconds // 32 - 4 seconds // 64 - 12 seconds // 128 - 42 seconds // 180 - 81 seconds // 360 - 308 seconds (LOL, 2GiB memory!) --jc Save a life; adopt a shelter animal. On Wed, Mar 21, 2018 at 11:50 AM, J.C. Wren <jcwren@jcwren.com> wrote: > The addition of hull() gets much closer to what I want, except I want to > keep the torus itself. From the previous image, I want to keep the yellow > and red sections, and remove the blue. > > > > > --jc > > Save a life; adopt a shelter animal. > > On Wed, Mar 21, 2018 at 11:38 AM, Ronaldo Persiano <rcmpersiano@gmail.com> > wrote: > >> As the torus transversal section diameter is greater than the block >> width, the difference will produce two separate parts. Is that what you >> want? If so, it would be better to generate separately each part. For >> 3d printing purposes, you may use a lower value of $fn with the benefit of >> a faster render. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >
N
NateTG
Wed, Mar 21, 2018 4:41 PM

Is this what you want?

<pre> sides=36; holder_width=28; bolt_dia=16.66; bolt_h_offset=5; bolt_v_offset=16; difference () { translate ([0, -5.5, 0]) cube ([holder_width, 5.5, bolt_v_offset]); translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset]) #rotate ([270, 360 - 1, 0]) difference() { cylinder(r=5.55,h=12,center=true); rotate_extrude (angle=180 + 2, convexity=10, $fn=sides) translate ([5.55, 0, 0]) circle (d=5.55, $fn=sides); } } </pre>

--
Sent from: http://forum.openscad.org/

Is this what you want? <pre> sides=36; holder_width=28; bolt_dia=16.66; bolt_h_offset=5; bolt_v_offset=16; difference () { translate ([0, -5.5, 0]) cube ([holder_width, 5.5, bolt_v_offset]); translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset]) #rotate ([270, 360 - 1, 0]) difference() { cylinder(r=5.55,h=12,center=true); rotate_extrude (angle=180 + 2, convexity=10, $fn=sides) translate ([5.55, 0, 0]) circle (d=5.55, $fn=sides); } } </pre> -- Sent from: http://forum.openscad.org/
JW
J.C. Wren
Wed, Mar 21, 2018 4:46 PM

That is exactly what I'm looking for. Thank you :)

--jc

Save a life; adopt a shelter animal.

On Wed, Mar 21, 2018 at 12:41 PM, NateTG nate-openscadforum@pedantic.org
wrote:

Is this what you want?

<pre> sides=36; holder_width=28; bolt_dia=16.66; bolt_h_offset=5; bolt_v_offset=16; difference () { translate ([0, -5.5, 0]) cube ([holder_width, 5.5, bolt_v_offset]); translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset]) #rotate ([270, 360 - 1, 0]) difference() { cylinder(r=5.55,h=12,center=true); rotate_extrude (angle=180 + 2, convexity=10, $fn=sides) translate ([5.55, 0, 0]) circle (d=5.55, $fn=sides); } } </pre>

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

That is *exactly* what I'm looking for. Thank you :) --jc Save a life; adopt a shelter animal. On Wed, Mar 21, 2018 at 12:41 PM, NateTG <nate-openscadforum@pedantic.org> wrote: > Is this what you want? > > <pre> > sides=36; > holder_width=28; > bolt_dia=16.66; > bolt_h_offset=5; > bolt_v_offset=16; > > difference () { > translate ([0, -5.5, 0]) > cube ([holder_width, 5.5, bolt_v_offset]); > translate ([bolt_h_offset + (bolt_dia / 2), -(5.5 / 2), bolt_v_offset]) > #rotate ([270, 360 - 1, 0]) > difference() { > cylinder(r=5.55,h=12,center=true); > rotate_extrude (angle=180 + 2, convexity=10, $fn=sides) > translate ([5.55, 0, 0]) > circle (d=5.55, $fn=sides); > } > } > </pre> > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >