difference() not working as expected with rotate_extrude()

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

difference() not working as expected with rotate_extrude()

jcwren
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.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: difference() not working as expected with rotate_extrude()

fred_dot_u
<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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: difference() not working as expected with rotate_extrude()

jcwren
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: difference() not working as expected with rotate_extrude()

Ronaldo
In reply to this post by jcwren
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: difference() not working as expected with rotate_extrude()

Ronaldo
In reply to this post by jcwren

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);
}​

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: difference() not working as expected with rotate_extrude()

jcwren
In reply to this post by Ronaldo
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: difference() not working as expected with rotate_extrude()

jcwren
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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: difference() not working as expected with rotate_extrude()

NateTG
In reply to this post by jcwren
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: difference() not working as expected with rotate_extrude()

jcwren
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org