discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

CSG doesn't work for this code

E
enzo
Sun, Mar 1, 2020 9:28 PM

Please, can anyone help me to understand what's wrong in this code for it
can't work the CSG (no error issued):

module pyramid_side(side, thickness)
{
linear_extrude(height = 2)
{
triangle_points =[[0,0],[side,0],[side/2, side * 1.5],[5, 5],[side - 5,
5],[side/2, side * 1.5 - 10]];
triangle_paths =[[0,1,2],[3,4,5]];
polygon(triangle_points,triangle_paths,10);
}
}
rotate([109.5, 0, 0])
translate([1, 0, 0])
pyramid_side(100);
rotate([109.5, 0, 90])
translate([-100, 0, 0])
pyramid_side(100);
rotate([109.5, 0, -90])
translate([1, -34, -95])
pyramid_side(100);
rotate([109.5, 0, 180])
translate([-100, -34, -95])
pyramid_side(100);

Preview seems ok, I guess it's not a manifold but how can I fix it?
Thanks

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

Please, can anyone help me to understand what's wrong in this code for it can't work the CSG (no error issued): module pyramid_side(side, thickness) { linear_extrude(height = 2) { triangle_points =[[0,0],[side,0],[side/2, side * 1.5],[5, 5],[side - 5, 5],[side/2, side * 1.5 - 10]]; triangle_paths =[[0,1,2],[3,4,5]]; polygon(triangle_points,triangle_paths,10); } } rotate([109.5, 0, 0]) translate([1, 0, 0]) pyramid_side(100); rotate([109.5, 0, 90]) translate([-100, 0, 0]) pyramid_side(100); rotate([109.5, 0, -90]) translate([1, -34, -95]) pyramid_side(100); rotate([109.5, 0, 180]) translate([-100, -34, -95]) pyramid_side(100); Preview seems ok, I guess it's not a manifold but how can I fix it? Thanks -- Sent from: http://forum.openscad.org/
M
MichaelAtOz
Sun, Mar 1, 2020 10:27 PM

enzo wrote

for it can't work the CSG (no error issued):

Works for me. I exported it and the STL looks OK.
What is "can't work the CSG"?


Admin - email* me if you need anything,  or if I've done something stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

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

enzo wrote > for it can't work the CSG (no error issued): Works for me. I exported it and the STL looks OK. What is "can't work the CSG"? ----- Admin - email* me if you need anything, or if I've done something stupid... * click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Sun, Mar 1, 2020 10:39 PM

You code is previewed and rendered fine. It is a manifold. You may not be
happy with the vertices of your model. Try to start from a full pyramid and
excavate it with difference().

module pyramid(height, side) {
linear_extrude(height,scale=0.1/height)
square(side,center=true);
}

You code is previewed and rendered fine. It is a manifold. You may not be happy with the vertices of your model. Try to start from a full pyramid and excavate it with difference(). module pyramid(height, side) { linear_extrude(height,scale=0.1/height) square(side,center=true); }
L
lar3ry
Tue, Mar 3, 2020 4:33 PM

Ronaldo wrote

You code is previewed and rendered fine. It is a manifold. You may not be
happy with the vertices of your model. Try to start from a full pyramid
and
excavate it with difference().

module pyramid(height, side) {
linear_extrude(height,scale=0.1/height)
square(side,center=true);
}

I took this one as a bit of a challenge, and this is what I came up with.
I basically used trial and error to size and position the cutters, but I
imagine math would be helpful in sizing everything correctly.

difference () {
pyramid(100,100);
sqcutter();
tricutter();
rotate([0,0,90])
tricutter();
}
module pyramid(height, side) {
linear_extrude(height,scale=0.1/height)
square(side,center=true);
}

module tricutter () {
rotate([0,-90,0])
translate([32,0,-60])
linear_extrude(120)
scale ([1.1,1,1])
circle(50, $fn=3);
}

module sqcutter() {

linear_extrude(4.5)

	square(90,center=true);

}

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

Ronaldo wrote > You code is previewed and rendered fine. It is a manifold. You may not be > happy with the vertices of your model. Try to start from a full pyramid > and > excavate it with difference(). > > module pyramid(height, side) { > linear_extrude(height,scale=0.1/height) > square(side,center=true); > } I took this one as a bit of a challenge, and this is what I came up with. I basically used trial and error to size and position the cutters, but I imagine math would be helpful in sizing everything correctly. difference () { pyramid(100,100); sqcutter(); tricutter(); rotate([0,0,90]) tricutter(); } module pyramid(height, side) { linear_extrude(height,scale=0.1/height) square(side,center=true); } module tricutter () { rotate([0,-90,0]) translate([32,0,-60]) linear_extrude(120) scale ([1.1,1,1]) circle(50, $fn=3); } module sqcutter() { # linear_extrude(4.5) square(90,center=true); } -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Tue, Mar 3, 2020 4:57 PM

I haven't checked your code yet but it seems that it might be easier to
excavate with the pyramid itself.

I haven't checked your code yet but it seems that it might be easier to excavate with the pyramid itself.
L
lar3ry
Tue, Mar 3, 2020 7:27 PM

Ronaldo wrote

I haven't checked your code yet but it seems that it might be easier to
excavate with the pyramid itself.

I'd be interested to see how you could do that.
Yes, I can use the pyramid to hollow it out:

difference() {
pyramid(100,100);
translate ([0,0,-5])
pyramid(100,100);
}

module pyramid(height, side) {
linear_extrude(height,scale=0.1/height)
square(side,center=true);
}

But that still leaves the walls.
I could cut my code down some by eliminating sqcutter() and subsituting the
technique above:

difference () {
pyramid(100,100);
translate ([0,0,-5])
pyramid(100,100);
tricutter();
rotate([0,0,90])
tricutter();
}
module pyramid(height, side) {
linear_extrude(height,scale=0.1/height)
square(side,center=true);
}

module tricutter () {
rotate([0,-90,0])
translate([32,0,-60])
linear_extrude(120)
scale ([1.1,1,1])
circle(50, $fn=3);
}

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

Ronaldo wrote > I haven't checked your code yet but it seems that it might be easier to > excavate with the pyramid itself. I'd be interested to see how you could do that. Yes, I can use the pyramid to hollow it out: difference() { pyramid(100,100); translate ([0,0,-5]) pyramid(100,100); } module pyramid(height, side) { linear_extrude(height,scale=0.1/height) square(side,center=true); } But that still leaves the walls. I could cut my code down some by eliminating sqcutter() and subsituting the technique above: difference () { pyramid(100,100); translate ([0,0,-5]) pyramid(100,100); tricutter(); rotate([0,0,90]) tricutter(); } module pyramid(height, side) { linear_extrude(height,scale=0.1/height) square(side,center=true); } module tricutter () { rotate([0,-90,0]) translate([32,0,-60]) linear_extrude(120) scale ([1.1,1,1]) circle(50, $fn=3); } -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Wed, Mar 4, 2020 4:30 AM

I haven't checked your code yet but it seems that it might be easier to
excavate with the pyramid itself.

I'd be interested to see how you could do that.

There are many alternatives. Here is one:

module pyramid(height, side) {

linear_extrude(height,scale=0.1/height)

square(side,center=true);

}

module A(height,side,a,b,c,d)

difference(){

pyramid(150,100);

translate([ a, d, b]) pyramid(150,100);

translate([-a,-d, b]) pyramid(150,100);

translate([ 0, 0, c]) pyramid(150,100);

}

a = 5;

b = 4;

c = 11;

union() {

A(150,100,a,b,-c,-a);

A(150,100,a,b,-c, a);

}

You will need some trigonometry to calculate a, b and c from the pyramid
height and side and the width of the studs.

> > > I haven't checked your code yet but it seems that it might be easier to > > excavate with the pyramid itself. > > I'd be interested to see how you could do that. > There are many alternatives. Here is one: module pyramid(height, side) { linear_extrude(height,scale=0.1/height) square(side,center=true); } module A(height,side,a,b,c,d) difference(){ pyramid(150,100); translate([ a, d, b]) pyramid(150,100); translate([-a,-d, b]) pyramid(150,100); translate([ 0, 0, c]) pyramid(150,100); } a = 5; b = 4; c = 11; union() { A(150,100,a,b,-c,-a); A(150,100,a,b,-c, a); } You will need some trigonometry to calculate a, b and c from the pyramid height and side and the width of the studs.
L
lar3ry
Wed, Mar 4, 2020 5:14 AM

You've bent my brain, sir!

Took me a while to figure it out. Very clever.

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

You've bent my brain, sir! Took me a while to figure it out. Very clever. -- Sent from: http://forum.openscad.org/
P
Parkinbot
Wed, Mar 4, 2020 1:28 PM

Here's a fancy one, without any trigonometric stuff:
h=100;
s=60;
d = 5;

intersection()
{
linear_extrude(h, scale = 0, convexity = 5)
square(s, center = true);
for(i=[0:3])
rotate(i*90)
multmatrix([[1, 0, s/2/h], [0, 1, 0], [0, 0, 1]]) // skew x
translate([-(s-d)/2, 0, 0])
rotate([0,-90,0])
linear_extrude(d, center = true)
difference()
{
ci(s);
offset(-d)ci(s);
}
}

module ci(a)
{
r = a/3sqrt(3);
H = a/2
sqrt(3);
scale([h/H, 1, 1])
translate([r/2, 0])circle(r, $fn=3);
}

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

Here's a fancy one, without any trigonometric stuff: h=100; s=60; d = 5; intersection() { linear_extrude(h, scale = 0, convexity = 5) square(s, center = true); for(i=[0:3]) rotate(i*90) multmatrix([[1, 0, s/2/h], [0, 1, 0], [0, 0, 1]]) // skew x translate([-(s-d)/2, 0, 0]) rotate([0,-90,0]) linear_extrude(d, center = true) difference() { ci(s); offset(-d)ci(s); } } module ci(a) { r = a/3*sqrt(3); H = a/2*sqrt(3); scale([h/H, 1, 1]) translate([r/2, 0])circle(r, $fn=3); } -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Thu, Mar 5, 2020 3:33 AM

Here's a fancy one, without any trigonometric stuff:

You are right, Parkinbot: we don't need trigonometry here... neither fancy
skews :)

width  =  8;
height = 150;
side  = 100;

tower(height, side, width);

module tower(h, s, w)
difference(){
ds = w*(s+sqrt(ss+4hh))/h;
h0 = h
(s-ds)/s;
pyramid(h,s);
translate([0,0, w]) pyramid(h0,[2s, s-ds],[1,0.001]);
translate([0,0, w]) pyramid(h0,[s-ds, 2
s],[0.001,1]);
translate([0,0,-h+h0+w]) pyramid(h,s);
}

module pyramid(height, side, top=0)
linear_extrude(height,scale=top)
square(side,center=true);

> > Here's a fancy one, without any trigonometric stuff: > You are right, Parkinbot: we don't need trigonometry here... neither fancy skews :) width = 8; height = 150; side = 100; tower(height, side, width); module tower(h, s, w) difference(){ ds = w*(s+sqrt(s*s+4*h*h))/h; h0 = h*(s-ds)/s; pyramid(h,s); translate([0,0, w]) pyramid(h0,[2*s, s-ds],[1,0.001]); translate([0,0, w]) pyramid(h0,[s-ds, 2*s],[0.001,1]); translate([0,0,-h+h0+w]) pyramid(h,s); } module pyramid(height, side, top=0) linear_extrude(height,scale=top) square(side,center=true);