machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

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

machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

William Adams-2
I'm trying to work up some 3D modeling tutorials for the ShapeOko wiki ( http://www.shapeoko.com/wiki/index.php/Main_Page )

Is this a reasonable way to show a 30mm diamond stacked on a 45mm circle on a 50mm square?

translate([-25,-25,0]) {
        cube(size=[50,50,3]);
}
translate([0,0,2]) {
        cylinder(4,22.5,22.5);
}
rotate(a=45, v=[0,0,1]) {
        translate([-15,-15,5]) {
                cube(size=[30,30,4]);
        }
}

I guess it would be more elegant to set up a function where one provided four values (30, 45, 50 and 3mm (for the incremental height of each layer) in the example above) and got the same result programmatically --- should I research that and include it up-front as a matter of style / expression, or will the simpler form be okay (w/ a mention of the potential programmability)?

William

--
William Adams
senior graphic designer
Fry Communications
Sphinx of black quartz, judge my vow.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

Peter Falke
I would do it this way:

// cube

a=50;

ha=2;


//cylinder

r=45/2;

hr=3;


//diamond

d=30;

hd=4;



// cube

translate([0,0,ha/2])

cube([a,a,ha],center=true);



// cylinder

translate([0,0,ha])

cylinder(h=hr,r=r);


// diamond

translate([0,0,ha+hr+hd/2])

rotate(45)

cube([d,d,hd],center=true);



The nice thing in OpenSCAD is that U can change the size of things by just changing a number.

But to really get the most out of this U need to scale things in the correct way. If I change the height of

the inner cylinder than the position of the diamond needs to be adjusted accordingly. So I use hr (height of cylinder when translating the diamond.


Hope it helps.


Enjoy,


TakeItAndRun




On 23 April 2013 14:51, William Adams <[hidden email]> wrote:
I'm trying to work up some 3D modeling tutorials for the ShapeOko wiki ( http://www.shapeoko.com/wiki/index.php/Main_Page )

Is this a reasonable way to show a 30mm diamond stacked on a 45mm circle on a 50mm square?

translate([-25,-25,0]) {
        cube(size=[50,50,3]);
}
translate([0,0,2]) {
        cylinder(4,22.5,22.5);
}
rotate(a=45, v=[0,0,1]) {
        translate([-15,-15,5]) {
                cube(size=[30,30,4]);
        }
}

I guess it would be more elegant to set up a function where one provided four values (30, 45, 50 and 3mm (for the incremental height of each layer) in the example above) and got the same result programmatically --- should I research that and include it up-front as a matter of style / expression, or will the simpler form be okay (w/ a mention of the potential programmability)?

William

--
William Adams
senior graphic designer
Fry Communications
Sphinx of black quartz, judge my vow.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

Triffid Hunter
In reply to this post by William Adams-2
I'd do something like this:

$fa = 0.01; // allow $fs to work correctly
$fs=0.5; // segment length of circle circumference

r_square = 50;
r_circle = 45;
r_diamond = 30;
l_height = 3;

translate([0, 0, l_height * 0.5]) {
    cube([r_square,r_square,l_height], center=true);
    #linear_extrude(height=l_height * 1.5)
        circle(r=r_circle/2);
    cylinder(r=r_diamond/2, h=l_height * 2.5, $fn=4);
}

it:
1) shows selective use of named parameters, without which your code quickly becomes un-navigable
2) avoids co-planar faces which create non-manifold STLs, by ensuring that each primitive overlaps its neighbours
3) shows use of $fs special variable to set circle circumference segment length
4) shows use of $fn to set circle number of faces
5) shows use of center parameter to offset a primitive automatically
6) shows use of constants (openscad doesn't have true variables yet)
7) shows use of standard mathematical operators to adjust parameters of a 3d model (parametricity)
8) shows nesting
9) shows hoisting of a 2d primitive into 3d
10) shows highlighting of a particular part of the tree using # indicator


On 23 April 2013 22:51, William Adams <[hidden email]> wrote:
I'm trying to work up some 3D modeling tutorials for the ShapeOko wiki ( http://www.shapeoko.com/wiki/index.php/Main_Page )

Is this a reasonable way to show a 30mm diamond stacked on a 45mm circle on a 50mm square?

translate([-25,-25,0]) {
        cube(size=[50,50,3]);
}
translate([0,0,2]) {
        cylinder(4,22.5,22.5);
}
rotate(a=45, v=[0,0,1]) {
        translate([-15,-15,5]) {
                cube(size=[30,30,4]);
        }
}

I guess it would be more elegant to set up a function where one provided four values (30, 45, 50 and 3mm (for the incremental height of each layer) in the example above) and got the same result programmatically --- should I research that and include it up-front as a matter of style / expression, or will the simpler form be okay (w/ a mention of the potential programmability)?

William

--
William Adams
senior graphic designer
Fry Communications
Sphinx of black quartz, judge my vow.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

William Adams-2
On Apr 23, 2013, at 9:29 AM, Triffid Hunter wrote:

> I'd do something like this...

<snip> excellent example

> it:

<snip> list of 10 ways in which it shows much better working practices than my own naïve example.

Thanks!

Posted to the Shapeoko wiki (I hope that's okay?), along w/ a mention of and link to Peter Falke's example.

William

--
William Adams
senior graphic designer
Fry Communications
Sphinx of black quartz, judge my vow.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

Peter Falke
In reply to this post by Triffid Hunter
Hi,

point 2):
I used to 'clue' everything together with a small overlap of e=0.01 . But lately OpenSCAD leaned to deal with this problem and I stopped doing that. Stl`s with co-planar faces export fine, now .
Or is it that the slicer(s) have problems with these stl`s?

point 1 to 10)
Maybe not a good idea to teach all 10 different concepts in a tutorial with one small peace of code.  :-)

Sincerely,

TakeItAndRun



On 23 April 2013 15:29, Triffid Hunter <[hidden email]> wrote:
I'd do something like this:

$fa = 0.01; // allow $fs to work correctly
$fs=0.5; // segment length of circle circumference

r_square = 50;
r_circle = 45;
r_diamond = 30;
l_height = 3;

translate([0, 0, l_height * 0.5]) {
    cube([r_square,r_square,l_height], center=true);
    #linear_extrude(height=l_height * 1.5)
        circle(r=r_circle/2);
    cylinder(r=r_diamond/2, h=l_height * 2.5, $fn=4);
}

it:
1) shows selective use of named parameters, without which your code quickly becomes un-navigable
2) avoids co-planar faces which create non-manifold STLs, by ensuring that each primitive overlaps its neighbours
3) shows use of $fs special variable to set circle circumference segment length
4) shows use of $fn to set circle number of faces
5) shows use of center parameter to offset a primitive automatically
6) shows use of constants (openscad doesn't have true variables yet)
7) shows use of standard mathematical operators to adjust parameters of a 3d model (parametricity)
8) shows nesting
9) shows hoisting of a 2d primitive into 3d
10) shows highlighting of a particular part of the tree using # indicator



On 23 April 2013 22:51, William Adams <[hidden email]> wrote:
I'm trying to work up some 3D modeling tutorials for the ShapeOko wiki ( http://www.shapeoko.com/wiki/index.php/Main_Page )

Is this a reasonable way to show a 30mm diamond stacked on a 45mm circle on a 50mm square?

translate([-25,-25,0]) {
        cube(size=[50,50,3]);
}
translate([0,0,2]) {
        cylinder(4,22.5,22.5);
}
rotate(a=45, v=[0,0,1]) {
        translate([-15,-15,5]) {
                cube(size=[30,30,4]);
        }
}

I guess it would be more elegant to set up a function where one provided four values (30, 45, 50 and 3mm (for the incremental height of each layer) in the example above) and got the same result programmatically --- should I research that and include it up-front as a matter of style / expression, or will the simpler form be okay (w/ a mention of the potential programmability)?

William

--
William Adams
senior graphic designer
Fry Communications
Sphinx of black quartz, judge my vow.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

Peter Falke
In reply to this post by William Adams-2
Go for it.

TakeItAndRun


On 23 April 2013 15:41, William Adams <[hidden email]> wrote:
On Apr 23, 2013, at 9:29 AM, Triffid Hunter wrote:

> I'd do something like this...

<snip> excellent example

> it:

<snip> list of 10 ways in which it shows much better working practices than my own naïve example.

Thanks!

Posted to the Shapeoko wiki (I hope that's okay?), along w/ a mention of and link to Peter Falke's example.

William

--
William Adams
senior graphic designer
Fry Communications
Sphinx of black quartz, judge my vow.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

nophead
 But lately OpenSCAD leaned to deal with this problem and I stopped doing that.Stl`s with co-planar faces export fine, now .

Really? I thought it was a fundamental problem with CSG. I have small overlaps everywhere, can I now remove them? Since which version? I haven't heard of a change that addresses it.


On 23 April 2013 14:57, Peter Falke <[hidden email]> wrote:
Go for it.

TakeItAndRun


On 23 April 2013 15:41, William Adams <[hidden email]> wrote:
On Apr 23, 2013, at 9:29 AM, Triffid Hunter wrote:

> I'd do something like this...

<snip> excellent example

> it:

<snip> list of 10 ways in which it shows much better working practices than my own naïve example.

Thanks!

Posted to the Shapeoko wiki (I hope that's okay?), along w/ a mention of and link to Peter Falke's example.

William

--
William Adams
senior graphic designer
Fry Communications
Sphinx of black quartz, judge my vow.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

kintel
Administrator
On 2013-04-23, at 11:59 , nop head wrote:

> >  But lately OpenSCAD leaned to deal with this problem and I stopped doing that.Stl`s with co-planar faces export fine, now .
>
> Really? I thought it was a fundamental problem with CSG. I have small overlaps everywhere, can I now remove them? Since which version? I haven't heard of a change that addresses it.
>
I don't understand that either - we might possibly be more robust in some cases, but it might just be underlying changes we got by upgrading CGAL, or things accidentally improved when refactoring code.

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

Peter Falke
I just tested with the above code.
It exports without errors a stl-file.
And the primitives are just touching.
So I thought everything is fine.

Now, catching a bug is good.
But catching a no-bug, I must me lucky.

Or is there later on a problem with the slicer? I cant test that, as I dont slice (have no 3d-printer)
Could someone please check that out.

TakeItAndRun

TakeItAndRun


On 23 April 2013 18:04, Marius Kintel <[hidden email]> wrote:
On 2013-04-23, at 11:59 , nop head wrote:

> >  But lately OpenSCAD leaned to deal with this problem and I stopped doing that.Stl`s with co-planar faces export fine, now .
>
> Really? I thought it was a fundamental problem with CSG. I have small overlaps everywhere, can I now remove them? Since which version? I haven't heard of a change that addresses it.
>
I don't understand that either - we might possibly be more robust in some cases, but it might just be underlying changes we got by upgrading CGAL, or things accidentally improved when refactoring code.

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki

Triffid Hunter
In reply to this post by Peter Falke
On 23 April 2013 23:41, Peter Falke <[hidden email]> wrote:
point 2):
I used to 'clue' everything together with a small overlap of e=0.01 . But lately OpenSCAD leaned to deal with this problem and I stopped doing that. Stl`s with co-planar faces export fine, now .
Or is it that the slicer(s) have problems with these stl`s?

it's never a good idea. floating point imprecision means sometimes you'll have gaps and sometimes you won't. slicers definitely do not like them, even if they export to STL fine.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566