L
larry
Fri, Feb 13, 2026 1:07 AM
I don't think I should be struggling with this, but I have a module
that requires a diameter and a height for a cylinder.
I would like to call it with a vector; something like this:
specs=([20,5]); product(specs);
Then in the module product(), I would like to do something like
cylinder(d=diameter,h=thickness);
My problem is getting the two cylinder values out of the vector.
Larry
I don't think I should be struggling with this, but I have a module
that requires a diameter and a height for a cylinder.
I would like to call it with a vector; something like this:
specs=([20,5]); product(specs);
Then in the module product(), I would like to do something like
cylinder(d=diameter,h=thickness);
My problem is getting the two cylinder values out of the vector.
Larry
SL
Steve Lelievre
Fri, Feb 13, 2026 1:23 AM
You seem to be using an object variable so I think you can use
specs = object(a=[220,5]);
product(specs);
module product(specs) {cylinder(d=specs.a.x, h=specs.a.y);}
but why not keep it simple and use
specs = [220,5];
product(specs);
module product(specs) {cylinder(d=specs.x, h=specs.y);}
(remember .x and .y index the first and second elements of a vector)
Steve
On 2026-02-12 5:07 p.m., larry via Discuss wrote:
I don't think I should be struggling with this, but I have a module
that requires a diameter and a height for a cylinder.
I would like to call it with a vector; something like this:
specs=([20,5]); product(specs);
Then in the module product(), I would like to do something like
cylinder(d=diameter,h=thickness);
My problem is getting the two cylinder values out of the vector.
Larry
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
You seem to be using an object variable so I think you can use
> specs = object(a=[220,5]);
>
> product(specs);
>
> module product(specs) {cylinder(d=specs.a.x, h=specs.a.y);}
but why not keep it simple and use
> specs = [220,5];
>
> product(specs);
>
> module product(specs) {cylinder(d=specs.x, h=specs.y);}
(remember .x and .y index the first and second elements of a vector)
Steve
On 2026-02-12 5:07 p.m., larry via Discuss wrote:
> I don't think I should be struggling with this, but I have a module
> that requires a diameter and a height for a cylinder.
>
> I would like to call it with a vector; something like this:
>
> specs=([20,5]); product(specs);
>
> Then in the module product(), I would like to do something like
>
> cylinder(d=diameter,h=thickness);
>
> My problem is getting the two cylinder values out of the vector.
>
> Larry
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jon Bondy
Fri, Feb 13, 2026 1:25 AM
I'm sure there are smarter people than me here, but when I define
vectors, I write
specs = [20, 5];
Perhaps the parentheses are the culprit.
Then I would say, in module product(s)
cylinder(h = s[0], d = s[1]);
On 2/12/2026 8:07 PM, larry via Discuss wrote:
I don't think I should be struggling with this, but I have a module
that requires a diameter and a height for a cylinder.
I would like to call it with a vector; something like this:
specs=([20,5]); product(specs);
Then in the module product(), I would like to do something like
cylinder(d=diameter,h=thickness);
My problem is getting the two cylinder values out of the vector.
Larry
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
I'm sure there are smarter people than me here, but when I define
vectors, I write
specs = [20, 5];
Perhaps the parentheses are the culprit.
Then I would say, in module product(s)
cylinder(h = s[0], d = s[1]);
On 2/12/2026 8:07 PM, larry via Discuss wrote:
> I don't think I should be struggling with this, but I have a module
> that requires a diameter and a height for a cylinder.
>
> I would like to call it with a vector; something like this:
>
> specs=([20,5]); product(specs);
>
> Then in the module product(), I would like to do something like
>
> cylinder(d=diameter,h=thickness);
>
> My problem is getting the two cylinder values out of the vector.
>
> Larry
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
MM
Michael Marx (spintel)
Fri, Feb 13, 2026 1:28 AM
specs=[20,5];
echo(specs[0]);
echo(specs[1]);
/*
ECHO: 20
ECHO: 5
*/
-----Original Message-----
From: larry via Discuss [mailto:discuss@lists.openscad.org]
Sent: Friday, February 13, 2026 12:07 PM
To: discuss@lists.openscad.org
Cc: larry
Subject: [OpenSCAD] use of array to pass variables to a module.
I don't think I should be struggling with this, but I have a module
that requires a diameter and a height for a cylinder.
I would like to call it with a vector; something like this:
specs=([20,5]); product(specs);
Then in the module product(), I would like to do something like
cylinder(d=diameter,h=thickness);
My problem is getting the two cylinder values out of the vector.
Larry
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
specs=[20,5];
echo(specs[0]);
echo(specs[1]);
/*
ECHO: 20
ECHO: 5
*/
> -----Original Message-----
> From: larry via Discuss [mailto:discuss@lists.openscad.org]
> Sent: Friday, February 13, 2026 12:07 PM
> To: discuss@lists.openscad.org
> Cc: larry
> Subject: [OpenSCAD] use of array to pass variables to a module.
>
> I don't think I should be struggling with this, but I have a module
> that requires a diameter and a height for a cylinder.
>
> I would like to call it with a vector; something like this:
>
> specs=([20,5]); product(specs);
>
> Then in the module product(), I would like to do something like
>
> cylinder(d=diameter,h=thickness);
>
> My problem is getting the two cylinder values out of the vector.
>
> Larry
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
GH
gene heskett
Fri, Feb 13, 2026 2:33 AM
On 2/12/26 20:07, larry via Discuss wrote:
I don't think I should be struggling with this, but I have a module
that requires a diameter and a height for a cylinder.
I would like to call it with a vector; something like this:
specs=([20,5]); product(specs);
Then in the module product(), I would like to do something like
cylinder(d=diameter,h=thickness);
My problem is getting the two cylinder values out of the vector.
you can call the subroutine name(va,vb); where va and vb are then locals
to that subroutine if the module line opening the sub looks like this:
module name(va,vb) where you have previously defined or calculated the
values in the calling module. Then you can call the cylinder macro with
h=va,d=vb and it will use the passed values for your cylinder.. You can
pass a rather lengthy list of named variablesthat way.
Cheers, Gene Heskett, CET.
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
Don't poison our oceans, interdict drugs at the src.
On 2/12/26 20:07, larry via Discuss wrote:
> I don't think I should be struggling with this, but I have a module
> that requires a diameter and a height for a cylinder.
>
> I would like to call it with a vector; something like this:
>
> specs=([20,5]); product(specs);
>
> Then in the module product(), I would like to do something like
>
> cylinder(d=diameter,h=thickness);
>
> My problem is getting the two cylinder values out of the vector.
you can call the subroutine name(va,vb); where va and vb are then locals
to that subroutine if the module line opening the sub looks like this:
module name(va,vb) where you have previously defined or calculated the
values in the calling module. Then you can call the cylinder macro with
h=va,d=vb and it will use the passed values for your cylinder.. You can
pass a rather lengthy list of named variablesthat way.
> Larry
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email todiscuss-leave@lists.openscad.org
> .
Cheers, Gene Heskett, CET.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
Don't poison our oceans, interdict drugs at the src.
L
larry
Fri, Feb 13, 2026 4:17 AM
On Fri, 2026-02-13 at 12:28 +1100, Michael Marx (spintel) via Discuss
wrote:
specs=[20,5];
echo(specs[0]);
echo(specs[1]);
/*
ECHO: 20
ECHO: 5
*/
Thanks all! For some reason I thought the parentheses were needed.
-----Original Message-----
From: larry via Discuss [mailto:discuss@lists.openscad.org]
Sent: Friday, February 13, 2026 12:07 PM
To: discuss@lists.openscad.org
Cc: larry
Subject: [OpenSCAD] use of array to pass variables to a module.
I don't think I should be struggling with this, but I have a module
that requires a diameter and a height for a cylinder.
I would like to call it with a vector; something like this:
specs=([20,5]); product(specs);
Then in the module product(), I would like to do something like
cylinder(d=diameter,h=thickness);
My problem is getting the two cylinder values out of the vector.
Larry
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On Fri, 2026-02-13 at 12:28 +1100, Michael Marx (spintel) via Discuss
wrote:
> specs=[20,5];
> echo(specs[0]);
> echo(specs[1]);
> /*
> ECHO: 20
> ECHO: 5
> */
Thanks all! For some reason I thought the parentheses were needed.
>
> > -----Original Message-----
> > From: larry via Discuss [mailto:discuss@lists.openscad.org]
> > Sent: Friday, February 13, 2026 12:07 PM
> > To: discuss@lists.openscad.org
> > Cc: larry
> > Subject: [OpenSCAD] use of array to pass variables to a module.
> >
> > I don't think I should be struggling with this, but I have a module
> > that requires a diameter and a height for a cylinder.
> >
> > I would like to call it with a vector; something like this:
> >
> > specs=([20,5]); product(specs);
> >
> > Then in the module product(), I would like to do something like
> >
> > cylinder(d=diameter,h=thickness);
> >
> > My problem is getting the two cylinder values out of the vector.
> >
> > Larry
> >
> > _______________________________________________
> > 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
Fri, Feb 13, 2026 5:44 AM
On 2/12/2026 8:17 PM, larry via Discuss wrote:
On Fri, 2026-02-13 at 12:28 +1100, Michael Marx (spintel) via Discuss
wrote:
specs=[20,5];
echo(specs[0]);
echo(specs[1]);
/*
ECHO: 20
ECHO: 5
*/
Thanks all! For some reason I thought the parentheses were needed.
They are neither needed nor harmful.
On 2/12/2026 8:17 PM, larry via Discuss wrote:
> On Fri, 2026-02-13 at 12:28 +1100, Michael Marx (spintel) via Discuss
> wrote:
>> specs=[20,5];
>> echo(specs[0]);
>> echo(specs[1]);
>> /*
>> ECHO: 20
>> ECHO: 5
>> */
> Thanks all! For some reason I thought the parentheses were needed.
They are neither needed nor harmful.