discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Seems OK but errors re unnamed arguments

T
terrypingm@gmail.com
Sat, Feb 19, 2022 11:37 PM

I’ll try your interesting rotate_extrude suggestion tomorrow.  Never used that before. Two cylinders seemed intuitive. And, again,  my code works ok  so  I’m happy :-)

--
Terry

On 19 Feb 2022, at 23:05, Douglas Miller doug@milmac.com wrote:

On 2/19/2022 12:51 PM, David Phillip Oster wrote:

the difference needs a translate down so you don't have colliding planes:
Not if he uses the 'center' parameter properly, he doesn't. Instead of

cylinder(h=h, d1=d1, d2=d2, $fn);

he needs to use cylinder(h=h, d1=d1, d2=d2, center=center, $fn); and similarly on the subtracted inner cylinder.

Terry: your main issue throughout is that you're not sending the correct parameters to cylinder().

And as I've noted in a different message, the whole issue becomes moot and everything becomes much easier and faster if you make this figure by rotate_extrude()ing a parallelogram.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I’ll try your interesting rotate_extrude suggestion tomorrow. Never used that before. Two cylinders seemed intuitive. And, again, my code works ok so I’m happy :-) -- Terry > On 19 Feb 2022, at 23:05, Douglas Miller <doug@milmac.com> wrote: > > On 2/19/2022 12:51 PM, David Phillip Oster wrote: >> the difference needs a translate down so you don't have colliding planes: > Not if he uses the 'center' parameter properly, he doesn't. Instead of > >> cylinder(h=h, d1=d1, d2=d2, $fn); > > he needs to use cylinder(h=h, d1=d1, d2=d2, center=center, $fn); and similarly on the subtracted inner cylinder. > > Terry: your main issue throughout is that you're not sending the correct parameters to cylinder(). > > And as I've noted in a different message, the whole issue becomes moot and everything becomes much easier and faster if you make this figure by rotate_extrude()ing a parallelogram. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
T
Terry
Sun, Feb 20, 2022 3:19 PM

And as I've noted in a different message, the whole issue becomes moot
and everything becomes much easier and faster if you make this figure by
rotate_extrude()ing a parallelogram.

Sure does, definitely neater, thanks.

// Height = h
// Bottom diam = d1 (larger)
// Top diam = d2 (smaller, or equal)
// $fn = $fn (e.g. 24 for control knob)
// Thickness = t

module hollow_cyl_rx(h, d1, d2, $fn, t) {
rotate_extrude() polygon([[d1/2 - t,0], [d1/2,0], [d2/2,h], [d2/2 - t,h]]);
}

// EXAMPLE
hollow_cyl_rx(9, 36, 28, 24, 1);


BTW, is it general practice to include an example when writing a module, as I've
done here, or is there some downside?

Terry

>And as I've noted in a different message, the whole issue becomes moot >and everything becomes much easier and faster if you make this figure by >rotate_extrude()ing a parallelogram. Sure does, definitely neater, thanks. // Height = h // Bottom diam = d1 (larger) // Top diam = d2 (smaller, or equal) // $fn = $fn (e.g. 24 for control knob) // Thickness = t module hollow_cyl_rx(h, d1, d2, $fn, t) { rotate_extrude() polygon([[d1/2 - t,0], [d1/2,0], [d2/2,h], [d2/2 - t,h]]); } // EXAMPLE hollow_cyl_rx(9, 36, 28, 24, 1); -------------------- BTW, is it general practice to include an example when writing a module, as I've done here, or is there some downside? Terry
MM
Michael Möller
Sun, Feb 20, 2022 9:15 PM

An example is ALWAYS a good thing.

  1. It is a LOT more accurate than a description of the problem
  2. It saves the person who you hope can help you to construct a test
    example, to see what you could have done wrong
  3. It may even be a good nudge to something new and different for people
    just watching the mail thread
    Lastly, but probably firstly) Whilst constructing the example to show the
    problem you discover your mistake.

There is a HUGE caveat: The example has to be short. No one likes looking
at 100 lines of code. Rule-of-thumb: a Simple screen full (and dont cheat
by using 6pt font :-) )

Whether a PNG or GIF is as helpful as a .SCAD is debatable, depends on the
context

On Sun, 20 Feb 2022 at 16:20, Terry terrypingm@gmail.com wrote:

And as I've noted in a different message, the whole issue becomes moot
and everything becomes much easier and faster if you make this figure by
rotate_extrude()ing a parallelogram.

Sure does, definitely neater, thanks.

// Height = h
// Bottom diam = d1 (larger)
// Top diam = d2 (smaller, or equal)
// $fn = $fn (e.g. 24 for control knob)
// Thickness = t

module hollow_cyl_rx(h, d1, d2, $fn, t) {
rotate_extrude() polygon([[d1/2 - t,0], [d1/2,0], [d2/2,h], [d2/2 - t,h]]);
}

// EXAMPLE
hollow_cyl_rx(9, 36, 28, 24, 1);


BTW, is it general practice to include an example when writing a module,
as I've
done here, or is there some downside?

Terry


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

An example is ALWAYS a good thing. 1) It is a LOT more accurate than a description of the problem 2) It saves the person who you hope can help you to construct a test example, to see what you could have done wrong 3) It may even be a good nudge to something new and different for people just watching the mail thread Lastly, but probably firstly) Whilst constructing the example to show the problem you discover your mistake. There is a HUGE caveat: The example has to be short. No one likes looking at 100 lines of code. Rule-of-thumb: a Simple screen full (and dont cheat by using 6pt font :-) ) Whether a PNG or GIF is as helpful as a .SCAD is debatable, depends on the context On Sun, 20 Feb 2022 at 16:20, Terry <terrypingm@gmail.com> wrote: > > >And as I've noted in a different message, the whole issue becomes moot > >and everything becomes much easier and faster if you make this figure by > >rotate_extrude()ing a parallelogram. > > Sure does, definitely neater, thanks. > > // Height = h > // Bottom diam = d1 (larger) > // Top diam = d2 (smaller, or equal) > // $fn = $fn (e.g. 24 for control knob) > // Thickness = t > > module hollow_cyl_rx(h, d1, d2, $fn, t) { > rotate_extrude() polygon([[d1/2 - t,0], [d1/2,0], [d2/2,h], [d2/2 - t,h]]); > } > > // EXAMPLE > hollow_cyl_rx(9, 36, 28, 24, 1); > > -------------------- > > BTW, is it general practice to include an example when writing a module, > as I've > done here, or is there some downside? > > > Terry > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
T
terrypingm@gmail.com
Sun, Feb 20, 2022 9:59 PM

Thanks Michael.

--
Terry

On 20 Feb 2022, at 21:16, Michael Möller private2michael@gmail.com wrote:


An example is ALWAYS a good thing.

  1. It is a LOT more accurate than a description of the problem
  2. It saves the person who you hope can help you to construct a test example, to see what you could have done wrong
  3. It may even be a good nudge to something new and different for people just watching the mail thread
    Lastly, but probably firstly) Whilst constructing the example to show the problem you discover your mistake.

There is a HUGE caveat: The example has to be short. No one likes looking at 100 lines of code. Rule-of-thumb: a Simple screen full (and dont cheat by using 6pt font :-) )

Whether a PNG or GIF is as helpful as a .SCAD is debatable, depends on the context

On Sun, 20 Feb 2022 at 16:20, Terry terrypingm@gmail.com wrote:

And as I've noted in a different message, the whole issue becomes moot
and everything becomes much easier and faster if you make this figure by
rotate_extrude()ing a parallelogram.

Sure does, definitely neater, thanks.

// Height = h
// Bottom diam = d1 (larger)
// Top diam = d2 (smaller, or equal)
// $fn = $fn (e.g. 24 for control knob)
// Thickness = t

module hollow_cyl_rx(h, d1, d2, $fn, t) {
rotate_extrude() polygon([[d1/2 - t,0], [d1/2,0], [d2/2,h], [d2/2 - t,h]]);
}

// EXAMPLE
hollow_cyl_rx(9, 36, 28, 24, 1);


BTW, is it general practice to include an example when writing a module, as I've
done here, or is there some downside?

Terry


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Thanks Michael. -- Terry > On 20 Feb 2022, at 21:16, Michael Möller <private2michael@gmail.com> wrote: > >  > An example is ALWAYS a good thing. > > 1) It is a LOT more accurate than a description of the problem > 2) It saves the person who you hope can help you to construct a test example, to see what you could have done wrong > 3) It may even be a good nudge to something new and different for people just watching the mail thread > Lastly, but probably firstly) Whilst constructing the example to show the problem you discover your mistake. > > There is a HUGE caveat: The example has to be short. No one likes looking at 100 lines of code. Rule-of-thumb: a Simple screen full (and dont cheat by using 6pt font :-) ) > > Whether a PNG or GIF is as helpful as a .SCAD is debatable, depends on the context > >> On Sun, 20 Feb 2022 at 16:20, Terry <terrypingm@gmail.com> wrote: >> >> >And as I've noted in a different message, the whole issue becomes moot >> >and everything becomes much easier and faster if you make this figure by >> >rotate_extrude()ing a parallelogram. >> >> Sure does, definitely neater, thanks. >> >> // Height = h >> // Bottom diam = d1 (larger) >> // Top diam = d2 (smaller, or equal) >> // $fn = $fn (e.g. 24 for control knob) >> // Thickness = t >> >> module hollow_cyl_rx(h, d1, d2, $fn, t) { >> rotate_extrude() polygon([[d1/2 - t,0], [d1/2,0], [d2/2,h], [d2/2 - t,h]]); >> } >> >> // EXAMPLE >> hollow_cyl_rx(9, 36, 28, 24, 1); >> >> -------------------- >> >> BTW, is it general practice to include an example when writing a module, as I've >> done here, or is there some downside? >> >> >> Terry >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Mon, Feb 21, 2022 4:14 AM

On 2/19/2022 8:15 AM, Terry wrote:

As recommended I'm using modules as much as possible. I'd welcome any general critiques of this one (syntax, method, formatting, anything). But in particular why is it that my code seems to work OK, despite the two console errors "Too many unnamed arguments... What is wrong with those please?

I didn't see a complete explanation of the problem, and some answers
mixed in other problems that are interesting but not the precise
question asked, so ...

 cylinder(h, d1, d2, true, $fn); // ERROR? <-----------------------------

The cheat sheer is not clear on this point, but the page it points to
has more.

The positional arguments to cylinder are:

cylinder(h = height, r1 = BottomRadius, r2 = TopRadius, center = true/false);

It wants a maximum of four positional arguments. You gave it five.

Probably the best answer is to use named arguments.

It also says:

NOTE: If r, d, d1 or d2 are used they must be named.

And some additional notes:

You're trying to pass diameters, but those positional parameters are
radiuses.

You tried to pass the current value of $fn as an argument.  That would
rarely be correct.  You also made your module take $fn as an argument...
I'm actually surprised that isn't an error.  $ variables are magic; you
can pass them to any operation (module, object, et cetera) whether or
not that operation directly pays attention them, and they will be passed
down to anything that it calls.  If you call hollowCyl_full with $fn=24,
that value will be passed down to the underlying cylinder calls even if
nothing in hollowCyl does anything to pass it.

On 2/19/2022 8:15 AM, Terry wrote: > As recommended I'm using modules as much as possible. I'd welcome any general critiques of this one (syntax, method, formatting, anything). But in particular why is it that my code seems to work OK, despite the two console errors "Too many unnamed arguments... What is wrong with those please? I didn't see a complete explanation of the problem, and some answers mixed in other problems that are interesting but not the precise question asked, so ... > cylinder(h, d1, d2, true, $fn); // ERROR? <----------------------------- The cheat sheer is not clear on this point, but the page it points to has more. The positional arguments to cylinder are: cylinder(h = height, r1 = BottomRadius, r2 = TopRadius, center = true/false); It wants a maximum of four positional arguments. You gave it five. Probably the best answer is to use named arguments. It also says: NOTE: If r, d, d1 or d2 are used they must be named. --- And some additional notes: You're trying to pass diameters, but those positional parameters are radiuses. You tried to pass the current value of $fn as an argument.  That would rarely be correct.  You also made your module take $fn as an argument... I'm actually surprised that isn't an error.  $ variables are magic; you can pass them to any operation (module, object, et cetera) whether or not that operation directly pays attention them, and they will be passed down to anything that it calls.  If you call hollowCyl_full with $fn=24, that value will be passed down to the underlying cylinder calls even if nothing in hollowCyl does anything to pass it.