I can't get my text cutout to work

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

I can't get my text cutout to work

andersjoensson
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: I can't get my text cutout to work

JordanBrown
[ For anybody else:  the * in front of the mirror() invocation is the forum software saying "bold". ]

I think you're having two problems:
  • I think that one of the things you're seeing is rendering problems in the previewer.  Does it look different if you do F6 instead of F5?  Fix this by adding "convexity=10" to your linear_extrude().
  • What I see is a straightforward extrusion, not a difference / cutout.
Let's apply some indentation:
mirror([0,0,1]){
   difference(){
      translate([0,-33,30]){
         rotate(a=45, v=[1,0,0]){ 
            cube([34,3,50],center=true);
            //Navn i urholder
            rotate([0,-90,90]){
               translate([-8,-5,-10]){
                  linear_extrude(height=20, convexity=10){
                     text("NBL", $fn=150);
                  }
               }
            }
         }
      }
      ///trækker indersiden af cylinder fra
      cylinder(h=45, r=24, center=true, $fn=80);
      ///trækker skrå sider på fod fra
      translate([8,-52,0]){
         rotate(a=-15,v=[0,0,1]){
            cube([55,55,55]);
         }
      }
      mirror([1,0,0]){
         translate([8,-52,0]){
            rotate(a=-15,v=[0,0,1]){
               cube([55,55,55]);
            }
         }
      }
   }
}
//bagerste fod

Now the problem becomes more apparent.  You have a cube and the text, minus a cylinder, minus two cubes.

Option 1:  add in another difference():
mirror([0,0,1]){
    difference(){
        translate([0,-33,30]){
            rotate(a=45, v=[1,0,0]){ 
                difference() {			// NEW
                    cube([34,3,50],center=true);
                    //Navn i urholder
                    rotate([0,-90,90]){
                        translate([-8,-5,-10]){
                            linear_extrude(height=20, convexity=10){
                                text("NBL", $fn=150);
                            }
                        }
                    }
                }
            }
        }
        ///trækker indersiden af cylinder fra
        cylinder(h=45, r=24, center=true, $fn=80);
        ///trækker skrå sider på fod fra
        translate([8,-52,0]){
            rotate(a=-15,v=[0,0,1]){
                cube([55,55,55]);
            }
        }
        mirror([1,0,0]){
            translate([8,-52,0]){
                rotate(a=-15,v=[0,0,1]){
                    cube([55,55,55]);
                }
            }
        }
    }
}
//bagerste fod

Option 2:  Move the text out to be a child of the original difference() (and duplicate the transformations):

mirror([0,0,1]){
    difference(){
        translate([0,-33,30]){
            rotate(a=45, v=[1,0,0]){ 
                cube([34,3,50],center=true);
            }
        }
        translate([0,-33,30]){		// COPIED
            rotate(a=45, v=[1,0,0]){ 
                //Navn i urholder
                rotate([0,-90,90]){	// MOVED
                    translate([-8,-5,-10]){
                        linear_extrude(height=20, convexity=10){
                            text("NBL", $fn=150);
                        }
                    }
                }
            }
        }
        ///trækker indersiden af cylinder fra
        cylinder(h=45, r=24, center=true, $fn=80);
        ///trækker skrå sider på fod fra
        translate([8,-52,0]){
            rotate(a=-15,v=[0,0,1]){
                cube([55,55,55]);
            }
        }
        mirror([1,0,0]){
            translate([8,-52,0]){
                rotate(a=-15,v=[0,0,1]){
                    cube([55,55,55]);
                }
            }
        }
    }
}
//bagerste fod



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

Re: I can't get my text cutout to work

andersjoensson
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: I can't get my text cutout to work

JordanBrown
On 5/31/2018 12:46 AM, andersjoensson wrote:
Thank you so much. (:

Glad to be of assistance.
I ended up adding an extra difference and it looks great! Added a cube to
hold the 2 floating pieces in my B.

Or just don't have it punch all the way through.

But i don't really get how it makes a
difference, as you only moved it below my translate and rotate? Is there a
maximum of how many elements i can subtract with difference?

No, but look at the indentation.

When you say
difference() {
    A;
    B;
    C;
    ...
}
you are asking for A, subtract B, subtract C.  Each of A, B, and C can be arbitrarily complex.

Here's what you had written:
difference(){
    translate([0,-33,30]){
        rotate(a=45, v=[1,0,0]){ 
            cube([34,3,50],center=true);
            //Navn i urholder
            rotate([0,-90,90]){
                translate([-8,-5,-10]){
                    linear_extrude(height=20, convexity=10){
                        text("NBL", $fn=150);
                    }
                }
            }
        }
    }
    ///trækker indersiden af cylinder fra
    cylinder(h=45, r=24, center=true, $fn=80);
    ...

That entire "translate" block is the A in the difference operation.  The first thing being subtracted from the object, the B in the difference, is the cylinder.  You're saying something like (ignoring translates and rotates)

(cube plus text) minus cylinder minus cube minus cube

My "option 1", adding in another difference(), makes it be

(cube minus text) minus cylinder minus cube minus cube

and my "option 2", pulling the text out, makes it be

cube minus text minus cylinder minus cube minus cube

I guess I am just being blinded by my own hideous code. :-)

Indentation is your friend.  Be obsessive about it.


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