Can't figure out how to draw thin cylinders.

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

Can't figure out how to draw thin cylinders.

Doug Mcnutt
pcbradin = 2.5; // inside radius of cktboard
pcbradout = 5.0; // outside radius of cktboard
pcbthin = 1/16;  // thickness of circuit board
pcbthick = 1/8;  // thickness of the subtracted cylinder
render (convexity=100) difference()
{
color("red");
echo ("first",pcbthin, pcbthick);
color("red") cylinder(h=pcbthin,r=pcbradout,$fn=100,true);
echo ("second",pcbthin, pcbthick);
color("blue") cylinder(h=pcbthick ,r=pcbradin,$fn=100,true);
}
color("blue") cube([pcbthick,pcbradin,5], true);

It's a first pass into creating some 3D presentations. But it's also my
first time with the code.

I have a printed circuit board that needs to be circular with a hole in
the center. Gerber files I have handled, but I need to mount the thing
using ball bearings.

I'm failing to get a decent picture when I run the above which displays
the circuit board with a 1 "inch" thickness that just won't go down to
the 1/16 inch that's the real thickness.

I'm trying to subtract a smaller cylinder from one with an undesired
center. Without the "render" command the cylinders look OK and have the
requested colors but the smallest dimension I see is still one inch.

With the render as above all I get is an annulus with the right sized
hole but 1 inch thick. None of the colors, except for the test "cube" at
the bottom, are recognized.

Please hold my hand. I'm willing to admit I came from FORTRAN without a
date code but I like perl and ubuntu is like the old days.

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

Re: Can't figure out how to draw thin cylinders.

nophead
The reason it looked bad without render is you subtracted things with coincident faces. You should always avoid that with some overlap.

The reason you got heights of 1 is the extra true parameter. I don't think you can mix named and unnamed parameters.

This works:

pcbradin = 2.5; // inside radius of cktboard
pcbradout = 5.0; // outside radius of cktboard
pcbthin = 1/16;  // thickness of circuit board
pcbthick = 1/8;  // thickness of the subtracted cylinder
difference()
{
echo ("first",pcbthin, pcbthick);
color("red") cylinder(h=pcbthin,r=pcbradout,$fn=100);
echo ("second",pcbthin, pcbthick);
translate([0, 0, -1])
    color("blue") cylinder(h=pcbthick + 2 ,r=pcbradin,$fn=100);
}
color("blue") cube([pcbthick,pcbradin,5], true);


On 30 June 2016 at 15:55, Doug McNutt <[hidden email]> wrote:
pcbradin = 2.5; // inside radius of cktboard
pcbradout = 5.0; // outside radius of cktboard
pcbthin = 1/16;  // thickness of circuit board
pcbthick = 1/8;  // thickness of the subtracted cylinder
render (convexity=100) difference()
{
color("red");
echo ("first",pcbthin, pcbthick);
color("red") cylinder(h=pcbthin,r=pcbradout,$fn=100,true);
echo ("second",pcbthin, pcbthick);
color("blue") cylinder(h=pcbthick ,r=pcbradin,$fn=100,true);
}
color("blue") cube([pcbthick,pcbradin,5], true);

It's a first pass into creating some 3D presentations. But it's also my first time with the code.

I have a printed circuit board that needs to be circular with a hole in the center. Gerber files I have handled, but I need to mount the thing using ball bearings.

I'm failing to get a decent picture when I run the above which displays the circuit board with a 1 "inch" thickness that just won't go down to the 1/16 inch that's the real thickness.

I'm trying to subtract a smaller cylinder from one with an undesired center. Without the "render" command the cylinders look OK and have the requested colors but the smallest dimension I see is still one inch.

With the render as above all I get is an annulus with the right sized hole but 1 inch thick. None of the colors, except for the test "cube" at the bottom, are recognized.

Please hold my hand. I'm willing to admit I came from FORTRAN without a date code but I like perl and ubuntu is like the old days.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.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: Can't figure out how to draw thin cylinders.

Parkinbot
Another thing: OpenSCAD displays and exports in mm. To switch to inch you have to introduce a factor:

inch = 25.4;

pcbradin = 2.5*inch; // inside radius of cktboard
pcbradout = 5.0*inch; // outside radius of cktboard
pcbthin = 1/16*inch;  // thickness of circuit board
pcbthick = 1/8*inch;  // thickness of the subtracted cylinder
//render (convexity=1)
difference()
{
color("red");
echo ("first",pcbthin, pcbthick);
color("red") cylinder(h=pcbthin,r=pcbradout,$fn=100, center = true);
echo ("second",pcbthin, pcbthick);
color("blue") cylinder(h=pcbthick+1 ,r=pcbradin,$fn=100,center=true);
}
color("blue") cube([pcbthick,pcbradin,5*inch], center=true);

Reply | Threaded
Open this post in threaded view
|

Re: Can't figure out how to draw thin cylinders.

nophead
OpenScad is unit-less and so is STL. It is tools downstream that determine what the units are.

On 30 June 2016 at 16:35, Parkinbot <[hidden email]> wrote:
Another thing: OpenSCAD displays and exports in mm. To switch to inch you
have to introduce a factor:

inch = 25.4;

pcbradin = 2.5*inch; // inside radius of cktboard
pcbradout = 5.0*inch; // outside radius of cktboard
pcbthin = 1/16*inch;  // thickness of circuit board
pcbthick = 1/8*inch;  // thickness of the subtracted cylinder
//render (convexity=1)
difference()
{
color("red");
echo ("first",pcbthin, pcbthick);
color("red") cylinder(h=pcbthin,r=pcbradout,$fn=100, center = true);
echo ("second",pcbthin, pcbthick);
color("blue") cylinder(h=pcbthick+1 ,r=pcbradin,$fn=100,center=true);
}
color("blue") cube([pcbthick,pcbradin,5*inch], center=true);





--
View this message in context: http://forum.openscad.org/Can-t-figure-out-how-to-draw-thin-cylinders-tp17841p17844.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.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: Can't figure out how to draw thin cylinders.

Parkinbot
You are perfectly right. As almost all tools downstream will interpret units as mm, it's worth mentioning it, to prevent unexpected results.

And if you remind this discussion it is not advisable to use very small values in OpenSCAD, because there is some unexpected rounding "magic" going on behind the scenes. So it is not a good idea to use inches for a design that is going to be specified in fractions of inches.
Reply | Threaded
Open this post in threaded view
|

Re: Can't figure out how to draw thin cylinders.

Ronaldo
In reply to this post by nophead
nophead wrote
I don't think you can mix named and unnamed parameters.
Is this a general rule? If I define a function or module with arguments f(a=0,b=0,c=1), would be irregular to write a call like f(5,c=3) intending f(a=5,b=0,c=3) ?
I could not find any mention on this in the Wiki Manual except in the cylinder description.
Reply | Threaded
Open this post in threaded view
|

Re: Can't figure out how to draw thin cylinders.

Parkinbot
My experience is, you can mix named and unnamed parameters. But you have to take care.
The unnamed are counted by place. You can redefine a parameter multiple times. The last definition will win.  

test(10, c=20);
test(a=10, 20);
test(10, a=20, a=30, a=40);

module test(a = 1, b = 2, c=3) echo(a,b,c);