Welcome! Log In Create A New Profile

Advanced

How to fix rendering problem

Posted by appjaws1 
How to fix rendering problem
February 22, 2021 04:05AM
I needed to create a 9 sided cut out, with rounded points, from a cube. The following code works and displays correctly using F5 but useing F6 just produces a solid object.

What an I doing wrong?

height = 10; //height
radius = 35;
angles = [40, 360];
fn = 9;
tol = 0.2;
a = 180 / fn;
r = radius / cos(a);

module round(){
difference(){
cylinder(h=height,r=radius+1);
translate([0,0,-tol]) cylinder (h=height+2*tol,r=radius-1,$fn=100);
} }

module sector(radius, angles, fn = 9) {
r = radius / cos(180 / fn);
step = -360 / fn;

points = concat([[0, 0]],
[for(a = [angles[0] : step : angles[1] - 360])
[r * cos(a), r * sin(a)]
],
[[r * cos(angles[1]), r * sin(angles[1])]]
);
circle(radius, $fn = fn);
}
module cutout(){
difference(){
scale([1,1,height])sector(radius, angles, fn);
translate([0,0,-height/2]) round();
} }

module combine(){
difference(){
cube([80,80,height],center=true);
translate ([-2,radius-3,-2])cube([4,10,8]);//cable slot
} }

difference(){
combine();
rotate([0,0,30]) cutout();
}

Edited 1 time(s). Last edit at 02/22/2021 04:06AM by appjaws1.


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Re: How to fix rendering problem
February 22, 2021 04:34AM
your ignoring the warnings

WARNING: Mixing 2D and 3D objects is not supported, in file , line 30
WARNING: Ignoring 3D child object for 2D operation, in file , line 30
WARNING: Mixing 2D and 3D objects is not supported, in file , line 41
WARNING: Ignoring 2D child object for 3D operation, in file , line 41

Cant use circle

Try this

height = 10; //height
radius = 35;
angles = [40, 360];
fn = 9;
tol = 0.2;
a = 180 / fn;
r = radius / cos(a);

module round(){
difference(){
cylinder(h=height,r=radius+1);
translate([0,0,-tol]) cylinder (h=height+2*tol,r=radius-1,$fn=100);
} }

module sector(radius, angles, fn = 9) {
r = radius / cos(180 / fn);
step = -360 / fn;

//points = concat([[0, 0]],
//[for(a = [angles[0] : step : angles[1] - 360])
//[r * cos(a), r * sin(a)]
//],
//[[r * cos(angles[1]), r * sin(angles[1])]]
//);
cylinder(h=height, r = radius, $fn = fn);
}
module cutout(){
difference(){
translate([0,0,-height]) scale([1,1,height])sector(radius, angles, fn);
translate([0,0,-height/2]) round();
} }

module combine(){
difference(){
cube([80,80,height],center=true);
translate ([-2,radius-3,-2])cube([4,10,8]);//cable slot
} }

difference(){
combine();
rotate([0,0,30]) cutout();
}
Re: How to fix rendering problem
February 22, 2021 04:45AM
Thank you so much @Dust that worked perfectly.


appjaws - Core XYUV Duet Ethernet Duex5
firmware 3.1.1 Web Interface 3.1.1
Ormerod 1-converted to laser engraver, Duet wifi
OpenSCAD version 2020.07
slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1
Sorry, only registered users may post in this forum.

Click here to login