Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
Not knowing what I'm doing, which is how I build my stuff, I removed the i = 0 line and moved the OneSet line into the loop, placed after the i = k *Z line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos <roosbob@wybatap.com> wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Hi fred,
Yes Fred that is the objective for part 2. Thank you. I kept it out of the loop thinking it would get the values assigned inside the loop.
But the Side list did not get more points with each iteration. How to really concat things?
Bob
Sunday, May 29, 2022, 11:31:26 AM, you wrote:
Not knowing what I'm doing, which is how I build my stuff, I removed the i = 0 line and moved the OneSet line into the loop, placed after the i = k *Z line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos roosbob@wybatap.com wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
My guess on that part is that your code reads Side=concat(Side,OneSet);That won't work, as it's a "reassignment" prohibited by the structure of the language. Construct an intermediate assignment using a different name and it might work as desired.
On Sunday, May 29, 2022, 11:46:04 AM EDT, Bob Roos <roosbob@wybatap.com> wrote:
Hi fred,
Yes Fred that is the objective for part 2. Thank you. I kept it out of the loop thinking it would get the values assigned inside the loop.
But the Side list did not get more points with each iteration. How to really concat things?
Bob
Sunday, May 29, 2022, 11:31:26 AM, you wrote:
Not knowing what I'm doing, which is how I build my stuff, I removed the i = 0 line and moved the OneSet line into the loop, placed after the i = k *Z line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos <roosbob@wybatap.com> wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Hi fred,
I want the contents in Side to grow with each iteration. The help for concat uses only ECHO statements and does not show an example of growing a list using concat. That would be truly helpful.
Sunday, May 29, 2022, 11:57:51 AM, you wrote:
My guess on that part is that your code reads Side=concat(Side,OneSet);
That won't work, as it's a "reassignment" prohibited by the structure of the language. Construct an intermediate assignment using a different name and it might work as desired.
On Sunday, May 29, 2022, 11:46:04 AM EDT, Bob Roos roosbob@wybatap.com wrote:
Hi fred,
Yes Fred that is the objective for part 2. Thank you. I kept it out of the loop thinking it would get the values assigned inside the loop.
But the Side list did not get more points with each iteration. How to really concat things?
Bob
Sunday, May 29, 2022, 11:31:26 AM, you wrote:
Not knowing what I'm doing, which is how I build my stuff, I removed the i = 0 line and moved the OneSet line into the loop, placed after the i = k *Z line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos roosbob@wybatap.com wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
You can't grow a list in OpenSCAD because all variables are immutable. You
can only build a list incrementally using a list comprehension. See
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/List_Comprehensions
On Sun, 29 May 2022 at 17:13, Bob Roos roosbob@wybatap.com wrote:
Hi fred,
I want the contents in Side to grow with each iteration. The help for
concat uses only ECHO statements and does not show an example of growing a
list using concat. That would be truly helpful.
Sunday, May 29, 2022, 11:57:51 AM, you wrote:
My guess on that part is that your code reads Side=concat(Side,OneSet);
That won't work, as it's a "reassignment" prohibited by the structure of
the language. Construct an intermediate assignment using a different name
and it might work as desired.
On Sunday, May 29, 2022, 11:46:04 AM EDT, Bob Roos roosbob@wybatap.com
wrote:
Hi fred,
Yes Fred that is the objective for part 2. Thank you. I kept it out of
the loop thinking it would get the values assigned inside the loop.
But the Side list did not get more points with each iteration. How to
really concat things?
Bob
Sunday, May 29, 2022, 11:31:26 AM, you wrote:
Not knowing what I'm doing, which is how I build my stuff, I removed the i
= 0 line and moved the OneSet line into the loop, placed after the i = k *Z
line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30,
32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487],
[30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30,
40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316],
[30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30,
48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145],
[30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos roosbob@wybatap.com
wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is
not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
You can also do it recursively:
function make_list(i) = i > 1 ? concat(i, make_list(i-1)) : [i];
echo(make_list(10));
On Sun, May 29, 2022 at 11:20 AM nop head nop.head@gmail.com wrote:
You can't grow a list in OpenSCAD because all variables are immutable. You
can only build a list incrementally using a list comprehension. See
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/List_Comprehensions
On Sun, 29 May 2022 at 17:13, Bob Roos roosbob@wybatap.com wrote:
Hi fred,
I want the contents in Side to grow with each iteration. The help for
concat uses only ECHO statements and does not show an example of growing a
list using concat. That would be truly helpful.
Sunday, May 29, 2022, 11:57:51 AM, you wrote:
My guess on that part is that your code reads Side=concat(Side,OneSet);
That won't work, as it's a "reassignment" prohibited by the structure of
the language. Construct an intermediate assignment using a different name
and it might work as desired.
On Sunday, May 29, 2022, 11:46:04 AM EDT, Bob Roos roosbob@wybatap.com
wrote:
Hi fred,
Yes Fred that is the objective for part 2. Thank you. I kept it out of
the loop thinking it would get the values assigned inside the loop.
But the Side list did not get more points with each iteration. How to
really concat things?
Bob
Sunday, May 29, 2022, 11:31:26 AM, you wrote:
Not knowing what I'm doing, which is how I build my stuff, I removed the
i = 0 line and moved the OneSet line into the loop, placed after the i = k
*Z line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30,
32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487],
[30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30,
40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316],
[30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30,
48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145],
[30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos roosbob@wybatap.com
wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is
not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
roosbob@wybatap.com
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
Hi nop,
I tried list comprehension (as least as I understood it) and got the points I wanted but they are a vector withing a vector and not useable in polygon();
I noticed another question about concat. Maybe we can get both on track?
I want to add 4 points with each iteration and not sure how to delimit the FOR to include the 4 points without putting in extra [] pairs.
// router supports,[0,2TiersZ)]},[0,0]
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
Side=[[0,0],[W,0],for (a = [1:Tiers])[[W,(2*a)Z],[Xl,(1a)Z],[Xl,(2a)Z], [ W,(1+2a)*Z ]],[ 0,(3+Tiers)*Z ]];
echo(Side);
*polygon(Side);
Sunday, May 29, 2022, 12:17:46 PM, you wrote:
You can't grow a list in OpenSCAD because all variables are immutable. You can only build a list incrementally using a list comprehension. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/List_Comprehensions
On Sun, 29 May 2022 at 17:13, Bob Roos roosbob@wybatap.com wrote:
Hi fred,
I want the contents in Side to grow with each iteration. The help for concat uses only ECHO statements and does not show an example of growing a list using concat. That would be truly helpful.
Sunday, May 29, 2022, 11:57:51 AM, you wrote:
My guess on that part is that your code reads Side=concat(Side,OneSet);
That won't work, as it's a "reassignment" prohibited by the structure of the language. Construct an intermediate assignment using a different name and it might work as desired.
On Sunday, May 29, 2022, 11:46:04 AM EDT, Bob Roos roosbob@wybatap.com wrote:
Hi fred,
Yes Fred that is the objective for part 2. Thank you. I kept it out of the loop thinking it would get the values assigned inside the loop.
But the Side list did not get more points with each iteration. How to really concat things?
Bob
Sunday, May 29, 2022, 11:31:26 AM, you wrote:
Not knowing what I'm doing, which is how I build my stuff, I removed the i = 0 line and moved the OneSet line into the loop, placed after the i = k *Z line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos roosbob@wybatap.com wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
Use each to add a list as multiple elements.
On Sun, 29 May 2022, 21:02 Bob Roos, roosbob@wybatap.com wrote:
Hi nop,
I tried list comprehension (as least as I understood it) and got the
points I wanted but they are a vector withing a vector and not useable in
polygon();
I noticed another question about concat. Maybe we can get both on track?
I want to add 4 points with each iteration and not sure how to delimit the
FOR to include the 4 points without putting in extra [] pairs.
// router supports,[0,2TiersZ)]},[0,0]
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
Side=[[0,0],[W,0],for (a =
[1:Tiers])[[W,(2*a)Z],[Xl,(1a)Z],[Xl,(2a)Z], [ W,(1+2a)*Z ]],[
0,(3+Tiers)*Z ]];
echo(Side);
*polygon(Side);
Sunday, May 29, 2022, 12:17:46 PM, you wrote:
You can't grow a list in OpenSCAD because all variables are immutable. You
can only build a list incrementally using a list comprehension. See
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/List_Comprehensions
On Sun, 29 May 2022 at 17:13, Bob Roos roosbob@wybatap.com wrote:
Hi fred,
I want the contents in Side to grow with each iteration. The help for
concat uses only ECHO statements and does not show an example of growing a
list using concat. That would be truly helpful.
Sunday, May 29, 2022, 11:57:51 AM, you wrote:
My guess on that part is that your code reads Side=concat(Side,OneSet);
That won't work, as it's a "reassignment" prohibited by the structure of
the language. Construct an intermediate assignment using a different name
and it might work as desired.
On Sunday, May 29, 2022, 11:46:04 AM EDT, Bob Roos roosbob@wybatap.com
wrote:
Hi fred,
Yes Fred that is the objective for part 2. Thank you. I kept it out of
the loop thinking it would get the values assigned inside the loop.
But the Side list did not get more points with each iteration. How to
really concat things?
Bob
Sunday, May 29, 2022, 11:31:26 AM, you wrote:
Not knowing what I'm doing, which is how I build my stuff, I removed the
i = 0 line and moved the OneSet line into the loop, placed after the i = k
*Z line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30,
32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487],
[30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30,
40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316],
[30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30,
48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145],
[30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos roosbob@wybatap.com
wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is
not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com
roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Hi nop,
THANK YOU very much. Here is the finished item:
function flatten(l) = [ for (a = l) for (b = a) b ] ;
// router supports,[0,2TiersZ)]},[0,0]
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
Side=[[[0,0]],[[W,0]],for (a = [1:Tiers])[[W,(3*a-1)Z],[Xl,(3a-2)Z],[Xl,(3a-1)Z], [ W,(3a)Z ]],[[ W,(3Tiers+1)Z ]],[[ 0,(3Tiers+1)*Z ]]];
round2d(2)polygon(flatten(Side));
Sunday, May 29, 2022, 4:06:11 PM, you wrote:
Use each to add a list as multiple elements.
On Sun, 29 May 2022, 21:02 Bob Roos, roosbob@wybatap.com wrote:
Hi nop,
I tried list comprehension (as least as I understood it) and got the points I wanted but they are a vector withing a vector and not useable in polygon();
I noticed another question about concat. Maybe we can get both on track?
I want to add 4 points with each iteration and not sure how to delimit the FOR to include the 4 points without putting in extra [] pairs.
// router supports,[0,2TiersZ)]},[0,0]
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
Side=[[0,0],[W,0],for (a = [1:Tiers])[[W,(2*a)Z],[Xl,(1a)Z],[Xl,(2a)Z], [ W,(1+2a)*Z ]],[ 0,(3+Tiers)*Z ]];
echo(Side);
*polygon(Side);
Sunday, May 29, 2022, 12:17:46 PM, you wrote:
You can't grow a list in OpenSCAD because all variables are immutable. You can only build a list incrementally using a list comprehension. See https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/List_Comprehensions
On Sun, 29 May 2022 at 17:13, Bob Roos roosbob@wybatap.com wrote:
Hi fred,
I want the contents in Side to grow with each iteration. The help for concat uses only ECHO statements and does not show an example of growing a list using concat. That would be truly helpful.
Sunday, May 29, 2022, 11:57:51 AM, you wrote:
My guess on that part is that your code reads Side=concat(Side,OneSet);
That won't work, as it's a "reassignment" prohibited by the structure of the language. Construct an intermediate assignment using a different name and it might work as desired.
On Sunday, May 29, 2022, 11:46:04 AM EDT, Bob Roos roosbob@wybatap.com wrote:
Hi fred,
Yes Fred that is the objective for part 2. Thank you. I kept it out of the loop thinking it would get the values assigned inside the loop.
But the Side list did not get more points with each iteration. How to really concat things?
Bob
Sunday, May 29, 2022, 11:31:26 AM, you wrote:
Not knowing what I'm doing, which is how I build my stuff, I removed the i = 0 line and moved the OneSet line into the loop, placed after the i = k *Z line. The result is:
ECHO: [[0, 0], [30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]], 8.0829, [[30, 0], [30, 24.2487], [16, 16.1658], [16, 24.2487], [30, 32.3316]]
ECHO: [[0, 0], [30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]], 16.1658, [[30, 0], [30, 32.3316], [16, 24.2487], [16, 32.3316], [30, 40.4145]]
ECHO: [[0, 0], [30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]], 24.2487, [[30, 0], [30, 40.4145], [16, 32.3316], [16, 40.4145], [30, 48.4974]]
Is that the objective?
On Sunday, May 29, 2022, 11:18:23 AM EDT, Bob Roos roosbob@wybatap.com wrote:
Hello OpenSCAD,
I thinking I am caught in the variable scope trap, and the "OpenSCAD is not like a programming language" trap.
Thank you for your help.
// router supports
RD = 7; // rod diameter
Z = RD/cos(30); // elevation change
X = Z/tan(30); // horizontal change
W = 30; // overall width
Xl = W-X; // location of left edge of slot
Tiers = 3; // number of vertical sets
i=0;
OneSet = [[W,0],[W,2Z+i],[Xl,Z+i],[Xl,2Z+i],[W,3*Z+i]];
Side = [[0,0]];
for (k = [1:Tiers])
{
i = k * Z;
Side=concat(Side,OneSet);
echo(Side,i,OneSet);
}
--
Best regards,
Bob mailto:roosbob@wybatap.com
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
--
have Fun,
Bob mailto:roosbob@wybatap.com