discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Cylinders turn into cones

DM
Doug McNutt
Tue, Aug 2, 2016 4:02 PM

I'm using OpenSCAD version 2015.03-1  which seems to be the best I can
get for Ubuntu without learning a whole lot more about git. That may be
the problem.

I also appreciate the super fast reply when I couldn't get a subtraction
of a little cylinder from a bigger one. That got me into a much bigger
operation that's working well. But. . .

What is turning my screws into arrowheads? I have extracted 90 percent
of the otherwise working file and I'm trying to show a dozen machine
screws that will hold three rextruded together parts together. Below is
working code extracted from a file I wouldn't dare to post here.

Please advise if you see cylinders or cones!

file: doug02.scad

// Here we specify some dimensions which control everything
// Each item specified starts with "com"

// Data describing the bearings which may be metric or English when we
order them.
// Current item is kaydonbearings.com  SA060ARO or SA060CP0 or SA060XP0
combearingod = 6.525.4;  // outside diameter of a ball bearing in mm
combearingid = 6.0
25.4;  // inside diameter of a ball bearing in mm,
the "bore"
combearingyy = 25.4/4;  // Common, and editable, bearing thickness in mm
combearingsep = 25; // Symmetric, z coordinate difference between
bearing centers in mm

////// End of alterable dimensions ///////

// Begin drawing a picture by calling the modules each of which
describes a part or two.
// Parts can be left out by adding a // at the start of its line.

{
screwbrackets(0);
// others redacted
}

/////// Beginning of modules //////
module screwbrackets(screws)
{
screwlen = 16;
screwrad = 3;  // mm radius
count = 12;
percount = 360/count;
scwrad = -8 + combearingid/2;
for (angl=[0:percount:360])
{
xval=scwradcos(angl);
yval=scwrad
sin(angl);
echo (angl, xval, yval);
color("yellow")
translate([xval, yval, -screwlen/4]) cylinder(screwlen, screwrad, 0);
}
}
////////

I'm using OpenSCAD version 2015.03-1 which seems to be the best I can get for Ubuntu without learning a whole lot more about git. That may be the problem. I also appreciate the super fast reply when I couldn't get a subtraction of a little cylinder from a bigger one. That got me into a much bigger operation that's working well. But. . . What is turning my screws into arrowheads? I have extracted 90 percent of the otherwise working file and I'm trying to show a dozen machine screws that will hold three rextruded together parts together. Below is working code extracted from a file I wouldn't dare to post here. Please advise if you see cylinders or cones! file: doug02.scad // Here we specify some dimensions which control everything // Each item specified starts with "com" // Data describing the bearings which may be metric or English when we order them. // Current item is kaydonbearings.com SA060ARO or SA060CP0 or SA060XP0 combearingod = 6.5*25.4; // outside diameter of a ball bearing in mm combearingid = 6.0*25.4; // inside diameter of a ball bearing in mm, the "bore" combearingyy = 25.4/4; // Common, and editable, bearing thickness in mm combearingsep = 25; // Symmetric, z coordinate difference between bearing centers in mm ////// End of alterable dimensions /////// // Begin drawing a picture by calling the modules each of which describes a part or two. // Parts can be left out by adding a // at the start of its line. { screwbrackets(0); // others redacted } /////// Beginning of modules ////// module screwbrackets(screws) { screwlen = 16; screwrad = 3; // mm radius count = 12; percount = 360/count; scwrad = -8 + combearingid/2; for (angl=[0:percount:360]) { xval=scwrad*cos(angl); yval=scwrad*sin(angl); echo (angl, xval, yval); color("yellow") translate([xval, yval, -screwlen/4]) cylinder(screwlen, screwrad, 0); } } ////////
NH
nop head
Tue, Aug 2, 2016 4:33 PM

Try cylinder(h = screwlen, r = screwrad,)

On 2 August 2016 at 17:02, Doug McNutt dmcnutt@macnauchtan.com wrote:

I'm using OpenSCAD version 2015.03-1  which seems to be the best I can get
for Ubuntu without learning a whole lot more about git. That may be the
problem.

I also appreciate the super fast reply when I couldn't get a subtraction
of a little cylinder from a bigger one. That got me into a much bigger
operation that's working well. But. . .

What is turning my screws into arrowheads? I have extracted 90 percent of
the otherwise working file and I'm trying to show a dozen machine screws
that will hold three rextruded together parts together. Below is working
code extracted from a file I wouldn't dare to post here.

Please advise if you see cylinders or cones!

file: doug02.scad

// Here we specify some dimensions which control everything
// Each item specified starts with "com"

// Data describing the bearings which may be metric or English when we
order them.
// Current item is kaydonbearings.com  SA060ARO or SA060CP0 or SA060XP0
combearingod = 6.525.4;  // outside diameter of a ball bearing in mm
combearingid = 6.0
25.4;  // inside diameter of a ball bearing in mm, the
"bore"
combearingyy = 25.4/4;  // Common, and editable, bearing thickness in mm
combearingsep = 25; // Symmetric, z coordinate difference between bearing
centers in mm

////// End of alterable dimensions ///////

// Begin drawing a picture by calling the modules each of which describes
a part or two.
// Parts can be left out by adding a // at the start of its line.

{
screwbrackets(0);
// others redacted
}

/////// Beginning of modules //////
module screwbrackets(screws)
{
screwlen = 16;
screwrad = 3;  // mm radius
count = 12;
percount = 360/count;
scwrad = -8 + combearingid/2;
for (angl=[0:percount:360])
{
xval=scwradcos(angl);
yval=scwrad
sin(angl);
echo (angl, xval, yval);
color("yellow")
translate([xval, yval, -screwlen/4]) cylinder(screwlen,
screwrad, 0);
}
}
////////


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Try cylinder(h = screwlen, r = screwrad,) On 2 August 2016 at 17:02, Doug McNutt <dmcnutt@macnauchtan.com> wrote: > I'm using OpenSCAD version 2015.03-1 which seems to be the best I can get > for Ubuntu without learning a whole lot more about git. That may be the > problem. > > I also appreciate the super fast reply when I couldn't get a subtraction > of a little cylinder from a bigger one. That got me into a much bigger > operation that's working well. But. . . > > What is turning my screws into arrowheads? I have extracted 90 percent of > the otherwise working file and I'm trying to show a dozen machine screws > that will hold three rextruded together parts together. Below is working > code extracted from a file I wouldn't dare to post here. > > Please advise if you see cylinders or cones! > > file: doug02.scad > > // Here we specify some dimensions which control everything > // Each item specified starts with "com" > > // Data describing the bearings which may be metric or English when we > order them. > // Current item is kaydonbearings.com SA060ARO or SA060CP0 or SA060XP0 > combearingod = 6.5*25.4; // outside diameter of a ball bearing in mm > combearingid = 6.0*25.4; // inside diameter of a ball bearing in mm, the > "bore" > combearingyy = 25.4/4; // Common, and editable, bearing thickness in mm > combearingsep = 25; // Symmetric, z coordinate difference between bearing > centers in mm > > ////// End of alterable dimensions /////// > > // Begin drawing a picture by calling the modules each of which describes > a part or two. > // Parts can be left out by adding a // at the start of its line. > > { > screwbrackets(0); > // others redacted > } > > /////// Beginning of modules ////// > module screwbrackets(screws) > { > screwlen = 16; > screwrad = 3; // mm radius > count = 12; > percount = 360/count; > scwrad = -8 + combearingid/2; > for (angl=[0:percount:360]) > { > xval=scwrad*cos(angl); > yval=scwrad*sin(angl); > echo (angl, xval, yval); > color("yellow") > translate([xval, yval, -screwlen/4]) cylinder(screwlen, > screwrad, 0); > } > } > //////// > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
DM
Doug McNutt
Tue, Aug 2, 2016 5:14 PM

On 08/02/2016 12:33 PM, nop head wrote:

Try cylinder(h = screwlen, r = screwrad,)

Wow.  I like this list and the answer quickly got me thinking right but
something is still strange:

//works translate([xval, yval, -screwlen/4]) cylinder(screwlen, r =
screwrad, center = true);
//works translate([xval, yval, -screwlen/4]) cylinder(h = screwlen, r =
screwrad, center = true);
//fails translate([xval, yval, -screwlen/4]) cylinder(h = screwlen, r =
screwrad, 0);
//works translate([xval, yval, -screwlen/4]) cylinder(screwlen, r =
screwrad, center = true);
//cones translate([xval, yval, -screwlen/4]) cylinder(screwlen,
screwrad, center = true);

It looks as though the real problem is the centering but the r= seems
necessary while the h= sometimes helps.

But it's working OK now and I can go back to harder things. Sincere thanks.

On 08/02/2016 12:33 PM, nop head wrote: > Try cylinder(h = screwlen, r = screwrad,) Wow. I like this list and the answer quickly got me thinking right but something is still strange: //works translate([xval, yval, -screwlen/4]) cylinder(screwlen, r = screwrad, center = true); //works translate([xval, yval, -screwlen/4]) cylinder(h = screwlen, r = screwrad, center = true); //fails translate([xval, yval, -screwlen/4]) cylinder(h = screwlen, r = screwrad, 0); //works translate([xval, yval, -screwlen/4]) cylinder(screwlen, r = screwrad, center = true); //cones translate([xval, yval, -screwlen/4]) cylinder(screwlen, screwrad, center = true); It looks as though the real problem is the centering but the r= seems necessary while the h= sometimes helps. But it's working OK now and I can go back to harder things. Sincere thanks.
DM
doug moen
Tue, Aug 2, 2016 6:09 PM

Don't use cylinder with positional arguments. Only use labeled arguments,
otherwise you get a surprise.

On 2 August 2016 at 13:14, Doug McNutt dmcnutt@macnauchtan.com wrote:

On 08/02/2016 12:33 PM, nop head wrote:

Try cylinder(h = screwlen, r = screwrad,)

Wow.  I like this list and the answer quickly got me thinking right but
something is still strange:

//works        translate([xval, yval, -screwlen/4]) cylinder(screwlen, r
= screwrad, center = true);
//works        translate([xval, yval, -screwlen/4]) cylinder(h =
screwlen, r = screwrad, center = true);
//fails        translate([xval, yval, -screwlen/4]) cylinder(h =
screwlen, r = screwrad, 0);
//works        translate([xval, yval, -screwlen/4]) cylinder(screwlen, r
= screwrad, center = true);
//cones        translate([xval, yval, -screwlen/4]) cylinder(screwlen,
screwrad, center = true);

It looks as though the real problem is the centering but the r= seems
necessary while the h= sometimes helps.

But it's working OK now and I can go back to harder things. Sincere thanks.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Don't use `cylinder` with positional arguments. Only use labeled arguments, otherwise you get a surprise. On 2 August 2016 at 13:14, Doug McNutt <dmcnutt@macnauchtan.com> wrote: > > On 08/02/2016 12:33 PM, nop head wrote: > >> Try cylinder(h = screwlen, r = screwrad,) >> > > Wow. I like this list and the answer quickly got me thinking right but > something is still strange: > > //works translate([xval, yval, -screwlen/4]) cylinder(screwlen, r > = screwrad, center = true); > //works translate([xval, yval, -screwlen/4]) cylinder(h = > screwlen, r = screwrad, center = true); > //fails translate([xval, yval, -screwlen/4]) cylinder(h = > screwlen, r = screwrad, 0); > //works translate([xval, yval, -screwlen/4]) cylinder(screwlen, r > = screwrad, center = true); > //cones translate([xval, yval, -screwlen/4]) cylinder(screwlen, > screwrad, center = true); > > It looks as though the real problem is the centering but the r= seems > necessary while the h= sometimes helps. > > But it's working OK now and I can go back to harder things. Sincere thanks. > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > >
TP
Torsten Paul
Tue, Aug 2, 2016 6:39 PM

The positional parameters for cylinder are h, r1, r2 and center.
Defaults are h = r1 = r2 = 1 and center = false.

so:

cylinder(h = screwlen, r = screwrad, 0)

=> cylinder(h = screwlen, r = screwrad, h = 0)
// second h assignment is active, so no object generated

cylinder(screwlen, screwrad, center = true)

=> cylinder(h = screwlen, r1 = screwrad, center = true)
// cone as r2 = 1 as that's the default

I guess it's basically a very unexpected choice to have r1 and
r2 as positional parameter, so not using those for cylinder is
probably the best advice.
Maybe the documentation could be improved to include this
information, but it's still not going to be intuitive.

ciao,
Torsten.

The positional parameters for cylinder are h, r1, r2 and center. Defaults are h = r1 = r2 = 1 and center = false. so: cylinder(h = screwlen, r = screwrad, 0) => cylinder(h = screwlen, r = screwrad, h = 0) // second h assignment is active, so no object generated cylinder(screwlen, screwrad, center = true) => cylinder(h = screwlen, r1 = screwrad, center = true) // cone as r2 = 1 as that's the default I guess it's basically a very unexpected choice to have r1 and r2 as positional parameter, so not using those for cylinder is probably the best advice. Maybe the documentation could be improved to include this information, but it's still not going to be intuitive. ciao, Torsten.
MV
Maurice van Peursem
Thu, Aug 4, 2016 2:54 AM

You could simplify your code to (also getting rid of the redundant
iteration of angl):

// Here we specify some dimensions which control everything
// Each item specified starts with "com"

// Data describing the bearings which may be metric or English when
we order them.
// Current item is kaydonbearings.com  SA060ARO or SA060CP0 or SA060XP0
combearingod = 6.525.4;  // outside diameter of a ball bearing in mm
combearingid = 6.0
25.4;  // inside diameter of a ball bearing in mm,
the "bore"
combearingyy = 25.4/4;  // Common, and editable, bearing thickness in mm
combearingsep = 25; // Symmetric, z coordinate difference between
bearing centers in mm

////// End of alterable dimensions ///////

// Begin drawing a picture by calling the modules each of which
describes a part or two.
// Parts can be left out by adding a // at the start of its line.

screwbrackets(0);
// others redacted

/////// Beginning of modules //////
module screwbrackets(screws)
{
screwlen = 16;
screwrad = 3;  // mm radius
count = 12;
percount = 360/count;
scwrad = -8 + combearingid/2;
for (angl=[percount:percount:360])
rotate([0,0,angl])
translate([scwrad, 0, -screwlen/4])
cylinder(h=screwlen, r=screwrad);
}
////////

Maurice

I'm using OpenSCAD version 2015.03-1  which seems to be the best I
can get for Ubuntu without learning a whole lot more about git. That
may be the problem.

I also appreciate the super fast reply when I couldn't get a
subtraction of a little cylinder from a bigger one. That got me into
a much bigger operation that's working well. But. . .

What is turning my screws into arrowheads? I have extracted 90
percent of the otherwise working file and I'm trying to show a dozen
machine screws that will hold three rextruded together parts
together. Below is working code extracted from a file I wouldn't
dare to post here.

Please advise if you see cylinders or cones!

file: doug02.scad

// Here we specify some dimensions which control everything
// Each item specified starts with "com"

// Data describing the bearings which may be metric or English when
we order them.
// Current item is kaydonbearings.com  SA060ARO or SA060CP0 or SA060XP0
combearingod = 6.525.4;  // outside diameter of a ball bearing in mm
combearingid = 6.0
25.4;  // inside diameter of a ball bearing in
mm, the "bore"
combearingyy = 25.4/4;  // Common, and editable, bearing thickness in mm
combearingsep = 25; // Symmetric, z coordinate difference between
bearing centers in mm

////// End of alterable dimensions ///////

// Begin drawing a picture by calling the modules each of which
describes a part or two.
// Parts can be left out by adding a // at the start of its line.

{
screwbrackets(0);
// others redacted
}

/////// Beginning of modules //////
module screwbrackets(screws)
{
screwlen = 16;
screwrad = 3;  // mm radius
count = 12;
percount = 360/count;
scwrad = -8 + combearingid/2;
for (angl=[0:percount:360])
{
xval=scwradcos(angl);
yval=scwrad
sin(angl);
echo (angl, xval, yval);
color("yellow")
translate([xval, yval, -screwlen/4])
cylinder(screwlen, screwrad, 0);
}
}
////////


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

You could simplify your code to (also getting rid of the redundant iteration of angl): // Here we specify some dimensions which control everything // Each item specified starts with "com" // Data describing the bearings which may be metric or English when we order them. // Current item is kaydonbearings.com SA060ARO or SA060CP0 or SA060XP0 combearingod = 6.5*25.4; // outside diameter of a ball bearing in mm combearingid = 6.0*25.4; // inside diameter of a ball bearing in mm, the "bore" combearingyy = 25.4/4; // Common, and editable, bearing thickness in mm combearingsep = 25; // Symmetric, z coordinate difference between bearing centers in mm ////// End of alterable dimensions /////// // Begin drawing a picture by calling the modules each of which describes a part or two. // Parts can be left out by adding a // at the start of its line. screwbrackets(0); // others redacted /////// Beginning of modules ////// module screwbrackets(screws) { screwlen = 16; screwrad = 3; // mm radius count = 12; percount = 360/count; scwrad = -8 + combearingid/2; for (angl=[percount:percount:360]) rotate([0,0,angl]) translate([scwrad, 0, -screwlen/4]) cylinder(h=screwlen, r=screwrad); } //////// Maurice >I'm using OpenSCAD version 2015.03-1 which seems to be the best I >can get for Ubuntu without learning a whole lot more about git. That >may be the problem. > >I also appreciate the super fast reply when I couldn't get a >subtraction of a little cylinder from a bigger one. That got me into >a much bigger operation that's working well. But. . . > >What is turning my screws into arrowheads? I have extracted 90 >percent of the otherwise working file and I'm trying to show a dozen >machine screws that will hold three rextruded together parts >together. Below is working code extracted from a file I wouldn't >dare to post here. > >Please advise if you see cylinders or cones! > >file: doug02.scad > >// Here we specify some dimensions which control everything >// Each item specified starts with "com" > >// Data describing the bearings which may be metric or English when >we order them. >// Current item is kaydonbearings.com SA060ARO or SA060CP0 or SA060XP0 >combearingod = 6.5*25.4; // outside diameter of a ball bearing in mm >combearingid = 6.0*25.4; // inside diameter of a ball bearing in >mm, the "bore" >combearingyy = 25.4/4; // Common, and editable, bearing thickness in mm >combearingsep = 25; // Symmetric, z coordinate difference between >bearing centers in mm > >////// End of alterable dimensions /////// > >// Begin drawing a picture by calling the modules each of which >describes a part or two. >// Parts can be left out by adding a // at the start of its line. > >{ >screwbrackets(0); >// others redacted >} > >/////// Beginning of modules ////// >module screwbrackets(screws) > { > screwlen = 16; > screwrad = 3; // mm radius > count = 12; > percount = 360/count; > scwrad = -8 + combearingid/2; > for (angl=[0:percount:360]) > { > xval=scwrad*cos(angl); > yval=scwrad*sin(angl); > echo (angl, xval, yval); > color("yellow") > translate([xval, yval, -screwlen/4]) >cylinder(screwlen, screwrad, 0); > } > } >//////// > >_______________________________________________ >OpenSCAD mailing list >Discuss@lists.openscad.org >http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org