CSG doesn't work for this code

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

CSG doesn't work for this code

enzo
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/

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

Re: CSG doesn't work for this code

MichaelAtOz
Administrator
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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.
Reply | Threaded
Open this post in threaded view
|

Re: CSG doesn't work for this code

Ronaldo
In reply to this post by enzo
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);
}

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

Re: CSG doesn't work for this code

lar3ry
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/

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

Re: CSG doesn't work for this code

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

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

Re: CSG doesn't work for this code

lar3ry
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/

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

Re: CSG doesn't work for this code

Ronaldo
> 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.

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

Re: CSG doesn't work for this code

lar3ry
You've bent my brain, sir!

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





--
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: CSG doesn't work for this code

Parkinbot
In reply to this post by Ronaldo
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/

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

Re: CSG doesn't work for this code

Ronaldo
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);


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

Re: CSG doesn't work for this code

enzo
In reply to this post by MichaelAtOz
Hi  Michael,

I tried again and this time OpenSCAD built the .stl!
I don't know why the last time id didn't!!!
Thanks for your answer!




--
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: CSG doesn't work for this code

enzo
In reply to this post by lar3ry
Hi lar3ry,

I went crazy to find a solid to subtract from the main pyramid at first but
I couldn't get it!
I've so much to learn about OpenSCAD!
Thanks a lot!



--
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: CSG doesn't work for this code

enzo
In reply to this post by Ronaldo
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.
>>
>
> There are many alternatives. Here is one:
>
> module pyramid(height, side) {
>
>   linear_extrude(height,scale=0.1/height)
>
>     square(side,center=true);
>
> }
>
> Hi Ronaldo,
>
> I see it works but just can't figure out why!!!
> I can't understand how the sutracting pyramids don't cut out the edges of
> the main pyramid!
> I need to study it again and again: I tried commenting some statements to
> simplify the model but had no success.
> Thanks for upgrading my OpenSCAD knowledge.
>
>
> 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.
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

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





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

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