Unexpected behavior of difference()

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

Unexpected behavior of difference()

GeorgeFlorian
Hello !

I am trying to make a screw hole inside a box lid.

The screw hole:

*module lid_screw_hole() {
    difference() {
        color("pink") cylinder(h=14,d=8,center=false);
        color("blue") cylinder(h=14,d=6,center=false);
    }
}*

And the lid:

*module plain_lid() {
translate([box_side-empty_space+10,0,0]) {
    color("red") plain_box(box_side-empty_space, box_side, 4);
   
    difference() {
        translate([wall,wall,0]) {
            color("green") plain_box(box_side-empty_space-(wall*2),
box_side-(wall*2), 14);
        }
        translate([wall*2,wall*2,0]) {
            color("yellow") plain_box(box_side-empty_space-(wall*2)*2,
box_side-(wall*2)*2, 14);
        }    
    }
}
}*


Naturally, I wanted to make a difference out of these two modules but
something strange happens:

*difference() {
    plain_lid();
    translate([182, wall+2, 0]) lid_screw_hole();
}*

</file/t2610/openscad1.png>

Making a *union()* doesn't help either. It just puts them together with no
actual hole inside the cylinder.

Any thoughts ?



--
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: Unexpected behavior of difference()

cacb
On 2019-07-22 12:17, GeorgeFlorian wrote:
> Any thoughts ?

Your code fragments are incomplete (many variables are undefined), there
is no way to know. Try attaching the complete source.

Carsten Arnholm

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

Re: Unexpected behavior of difference()

nophead
Also the picture isn't visible because the forum software is broken at the moment.

Why are you drilling a hole with a tube and not a cylinder?

The inner cylinder making the tube should be longer than the outer cylinder to prevent shimmering ends.

On Mon, 22 Jul 2019 at 11:57, <[hidden email]> wrote:
On 2019-07-22 12:17, GeorgeFlorian wrote:
> Any thoughts ?

Your code fragments are incomplete (many variables are undefined), there
is no way to know. Try attaching the complete source.

Carsten Arnholm

_______________________________________________
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: Unexpected behavior of difference()

MichaelAtOz's alias
In reply to this post by GeorgeFlorian

Here is the picture, you just copy the /file/... part and add it to forum.openscad.org

 

 

That is doing what you have told it to do.

Your hole has a d=8 cylinder hollowed out by d=6 cylinder, so you have a tube.

You then difference the tube from the lid. You get a tube 'hole' with the pin in the middle.

 

 

> -----Original Message-----

> From: Discuss [mailto:[hidden email]] On Behalf Of GeorgeFlorian

> Sent: Mon, 22 Jul 2019 20:17

> To: [hidden email]

> Subject: [OpenSCAD] Unexpected behavior of difference()

>

> Hello !

>

> I am trying to make a screw hole inside a box lid.

>

> The screw hole:

>

> *module lid_screw_hole() {

>     difference() {

>         color("pink") cylinder(h=14,d=8,center=false);

>         color("blue") cylinder(h=14,d=6,center=false);

>     }

> }*

>

> And the lid:

>

> *module plain_lid() {

> translate([box_side-empty_space+10,0,0]) {

>     color("red") plain_box(box_side-empty_space, box_side, 4);

>

>     difference() {

>         translate([wall,wall,0]) {

>             color("green") plain_box(box_side-empty_space-(wall*2),

> box_side-(wall*2), 14);

>         }

>         translate([wall*2,wall*2,0]) {

>             color("yellow") plain_box(box_side-empty_space-(wall*2)*2,

> box_side-(wall*2)*2, 14);

>         }

>     }

> }

> }*

>

>

> Naturally, I wanted to make a difference out of these two modules but

> something strange happens:

>

> *difference() {

>     plain_lid();

>     translate([182, wall+2, 0]) lid_screw_hole();

> }*

>

> </file/t2610/openscad1.png>

>

> Making a *union()* doesn't help either. It just puts them together with no

> actual hole inside the cylinder.

>

> Any thoughts ?

>

>

>

> --

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

>

> _______________________________________________

> OpenSCAD mailing list

> [hidden email]

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


Virus-free. www.avg.com

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

Re: Unexpected behavior of difference()

MichaelAtOz's alias
In reply to this post by GeorgeFlorian

Well that picture sort of overwhelmed the forum, resending...

 

Here is the picture, you just copy the /file/... part and add it to forum.openscad.org

 

 

 

 

 

 

That is doing what you have told it to do.

Your hole has a d=8 cylinder hollowed out by d=6 cylinder, so you have a tube.

You then difference the tube from the lid. You get a tube 'hole' with the pin in the middle.

 

 

> -----Original Message-----

> From: Discuss [mailto:[hidden email]] On Behalf Of GeorgeFlorian

> Sent: Mon, 22 Jul 2019 20:17

> To: [hidden email]

> Subject: [OpenSCAD] Unexpected behavior of difference()

>

> Hello !

>

> I am trying to make a screw hole inside a box lid.

>

> The screw hole:

>

> *module lid_screw_hole() {

>     difference() {

>         color("pink") cylinder(h=14,d=8,center=false);

>         color("blue") cylinder(h=14,d=6,center=false);

>     }

> }*

>

> And the lid:

>

> *module plain_lid() {

> translate([box_side-empty_space+10,0,0]) {

>     color("red") plain_box(box_side-empty_space, box_side, 4);

>

>     difference() {

>         translate([wall,wall,0]) {

>             color("green") plain_box(box_side-empty_space-(wall*2),

> box_side-(wall*2), 14);

>         }

>         translate([wall*2,wall*2,0]) {

>             color("yellow") plain_box(box_side-empty_space-(wall*2)*2,

> box_side-(wall*2)*2, 14);

>         }

>     }

> }

> }*

>

>

> Naturally, I wanted to make a difference out of these two modules but

> something strange happens:

>

> *difference() {

>     plain_lid();

>     translate([182, wall+2, 0]) lid_screw_hole();

> }*

>

> </file/t2610/openscad1.png>

>

> Making a *union()* doesn't help either. It just puts them together with no

> actual hole inside the cylinder.

>

> Any thoughts ?

>

>

>

> --

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

>

> _______________________________________________

> OpenSCAD mailing list

> [hidden email]

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


Virus-free. www.avg.com

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