Reputation: 424
I have problems with intersection() in OpenSCAD. Here is the code
intersection(){
rotate_extrude($fn=200)
translate([30, 0, 0])
circle(r=5);
translate([0,0,-50])
cube([100,100,100]);
};
It looks good
until you chance the point of view
It is not what I expected. How can I fix it?
Upvotes: 2
Views: 3028
Reputation: 121
Also check the wireframe (i.e. "Show edges") if they somehow edges ending in another edge, as you can get with intersection. Then if the total number of edges is high this graphical bug may occur.
I have had it on a number of objects, some refuse to render with F6, but almost always because there is an imported file in the model. F6 (render) always creates a model without the graphical glitch.
And then we have the annoyance when f5 takes a subsecond and f6 takes 15 minutes. Good thing that the coding window and saving isn't blocked when rendering, so you can always save the file and kill openscad when patience run low.
module cross_pipe_holder(thickness = cross_pipe_click_strength) {
$fn = 64;
sqrt2 = sqrt(2);
slope_height = holder_support_height - holder_full_dia_height;
y1 = holder_diameter/2;
y2 = y1 - slope_height;
r2 = sqrt2*y2;
pipe_click_y = slope_height - y2;
p = [ [-y1,0], [-y2, slope_height],
[y2, slope_height], [y1,0] ];
intersection() {
translate([cross_pipe_click_position,0])
rotate([0,90,0])
rotate([0,0,90])
linear_extrude(thickness, convexity = 10, center=true) {
difference() {
union() {
polygon(points = p);
translate([0,pipe_click_y])
circle(r = r2);
}
translate([0,slope_height])
circle(r = cross_diameter/2);
// less pointy click
x = r2/1.5;
translate([-x/2, slope_height])
square(x);
// cut off click overflow
translate([0,-r2])
square(2*r2, center = true);
}
}
translate([0,0,-1])
cylinder(h = holder_support_height+2, r = holder_diameter/2);
}
}
This module looks fine by itself but when adding in the part it is supposed to fit in as in a explosion diagram I got the glitch. But the edges are all messed up, because of the intersection that doesn't seem to recalculate those, on Preview (f5).
Upvotes: 0
Reputation: 47982
You probably should set the convexity
parameter in the extrusion, otherwise the renderer might assuming the object is convex, leading to the rendering errors in your screen shot.
For a torus, convexity should be set to at least 4, because a straight line can intersect it as many as four times. I believe the torus example in the docs sets the convexity to 10, which is overkill, but there doesn't seem to be a problem with erring in that direction.
Upvotes: 0
Reputation: 4286
if you only compile your code, the view might be damaged. Compile and render and you see your correct 3D-object. To verify export as stl, then import the stl-file in a new document and examine it
Upvotes: 3