discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Can't figure out how to draw thin cylinders.

DM
Doug McNutt
Thu, Jun 30, 2016 2:55 PM

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.

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.
NH
nop head
Thu, Jun 30, 2016 3:10 PM

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 dmcnutt@macnauchtan.com 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <dmcnutt@macnauchtan.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
Parkinbot
Thu, Jun 30, 2016 3:35 PM

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

inch = 25.4;

pcbradin = 2.5inch; // inside radius of cktboard
pcbradout = 5.0
inch; // outside radius of cktboard
pcbthin = 1/16inch;  // 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.

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.
NH
nop head
Thu, Jun 30, 2016 5:58 PM

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 rudolf@parkinbot.com wrote:

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

inch = 25.4;

pcbradin = 2.5inch; // inside radius of cktboard
pcbradout = 5.0
inch; // outside radius of cktboard
pcbthin = 1/16inch;  // 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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 <rudolf@parkinbot.com> 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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
Parkinbot
Thu, Jun 30, 2016 10:26 PM

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
http://forum.openscad.org/strange-polygon-behaviour-in-small-scale-tp17390.html
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.

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

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 <http://forum.openscad.org/strange-polygon-behaviour-in-small-scale-tp17390.html> 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. -- View this message in context: http://forum.openscad.org/Can-t-figure-out-how-to-draw-thin-cylinders-tp17841p17846.html Sent from the OpenSCAD mailing list archive at Nabble.com.
R
Ronaldo
Thu, Jun 30, 2016 10:32 PM

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.

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

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. -- View this message in context: http://forum.openscad.org/Can-t-figure-out-how-to-draw-thin-cylinders-tp17841p17847.html Sent from the OpenSCAD mailing list archive at Nabble.com.
P
Parkinbot
Thu, Jun 30, 2016 10:43 PM

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

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

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); -- View this message in context: http://forum.openscad.org/Can-t-figure-out-how-to-draw-thin-cylinders-tp17841p17848.html Sent from the OpenSCAD mailing list archive at Nabble.com.