### Creating arrays

JW
Joe Weinpert
Sat, May 7, 2022 4:28 PM

Having a problem understanding the "for" function.  Heck, I'm having a
problem understanding programs where all the variables are calculated at
compile time and not runtime.

I have an array of 11 *svg *strings named "svgArray" indexed as 0-10.
This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l
4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the pathbuilder
library function svgPoints().  The above string is converted into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747,
9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242],
[60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971,
14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857],
[67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named "pathArray"
to match each one in the "svgArray".  This means I have to loop through
the "svgArray", convert the current one to a point array using the
svgPoints() function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays throughout the

Having a problem understanding the "*for*" function. Heck, I'm having a problem understanding programs where all the variables are calculated at compile time and not runtime. I have an array of 11 *svg *strings named "*svgArray"* indexed as 0-10. This one is from index 4: ["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l 4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"] svg strings can be converted to a *point array* using the *pathbuilder* library function svgPoints(). The above string is converted into this: [[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857], [67.1286, 6.89428], [64.5886, 6.89428]] But ... I would like to create an indexed array of the points named "*pathArray*" to match each one in the "*svgArray*". This means I have to loop through the "*svgArray*", convert the current one to a point array using the *svgPoints*() function then append it to the "*pathArray*" being generated. How can I do that so I can use the array of point arrays throughout the rest of the scad program?
HL
Hans L
Sat, May 7, 2022 4:41 PM

You would do something like this, if I'm understanding your problem correctly:
pathArray = [for(element = svgArray) svgPoints(element)];

On Sat, May 7, 2022 at 11:28 AM Joe Weinpert joe.weinpert@gmail.com wrote:

Having a problem understanding the "for" function.  Heck, I'm having a problem understanding programs where all the variables are calculated at compile time and not runtime.

I have an array of 11 svg strings named "svgArray" indexed as 0-10.  This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l 4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the pathbuilder library function svgPoints().  The above string is converted into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857], [67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named "pathArray" to match each one in the "svgArray".  This means I have to loop through the "svgArray", convert the current one to a point array using the svgPoints() function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays throughout the rest of the scad program?

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

You would do something like this, if I'm understanding your problem correctly: pathArray = [for(element = svgArray) svgPoints(element)]; On Sat, May 7, 2022 at 11:28 AM Joe Weinpert <joe.weinpert@gmail.com> wrote: > > Having a problem understanding the "for" function. Heck, I'm having a problem understanding programs where all the variables are calculated at compile time and not runtime. > > I have an array of 11 svg strings named "svgArray" indexed as 0-10. This one is from index 4: > > ["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l 4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"] > > svg strings can be converted to a point array using the pathbuilder library function svgPoints(). The above string is converted into this: > > [[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857], [67.1286, 6.89428], [64.5886, 6.89428]] > > But ... > > I would like to create an indexed array of the points named "pathArray" to match each one in the "svgArray". This means I have to loop through the "svgArray", convert the current one to a point array using the svgPoints() function then append it to the "pathArray" being generated. > > How can I do that so I can use the array of point arrays throughout the rest of the scad program? > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JW
Joe Weinpert
Sat, May 7, 2022 5:07 PM

Seems to be working.  Thanks!  What is the purpose of the brackets in

On Sat, May 7, 2022 at 12:42 PM Hans L thehans@gmail.com wrote:

You would do something like this, if I'm understanding your problem
correctly:
pathArray = [for(element = svgArray) svgPoints(element)];

On Sat, May 7, 2022 at 11:28 AM Joe Weinpert joe.weinpert@gmail.com
wrote:

Having a problem understanding the "for" function.  Heck, I'm having a

problem understanding programs where all the variables are calculated at
compile time and not runtime.

I have an array of 11 svg strings named "svgArray" indexed as 0-10.

This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l

4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the pathbuilder

library function svgPoints().  The above string is converted into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747,

9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242],
[60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971,
14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857],
[67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named "pathArray"

to match each one in the "svgArray".  This means I have to loop through the
"svgArray", convert the current one to a point array using the svgPoints()
function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays throughout the

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

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

Seems to be working. Thanks! What is the purpose of the brackets in openSCAD? On Sat, May 7, 2022 at 12:42 PM Hans L <thehans@gmail.com> wrote: > You would do something like this, if I'm understanding your problem > correctly: > pathArray = [for(element = svgArray) svgPoints(element)]; > > On Sat, May 7, 2022 at 11:28 AM Joe Weinpert <joe.weinpert@gmail.com> > wrote: > > > > Having a problem understanding the "for" function. Heck, I'm having a > problem understanding programs where all the variables are calculated at > compile time and not runtime. > > > > I have an array of 11 svg strings named "svgArray" indexed as 0-10. > This one is from index 4: > > > > ["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l > 4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"] > > > > svg strings can be converted to a point array using the pathbuilder > library function svgPoints(). The above string is converted into this: > > > > [[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747, > 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242], > [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971, > 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857], > [67.1286, 6.89428], [64.5886, 6.89428]] > > > > But ... > > > > I would like to create an indexed array of the points named "pathArray" > to match each one in the "svgArray". This means I have to loop through the > "svgArray", convert the current one to a point array using the svgPoints() > function then append it to the "pathArray" being generated. > > > > How can I do that so I can use the array of point arrays throughout the > rest of the scad program? > > > > > > _______________________________________________ > > 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 >
AM
Sat, May 7, 2022 5:18 PM

The brackets make the item a list, just like in the example [1,2,3].
Without the brackets it's just like a bunch of numbers, like writing
1,2,3.  It's the same with for.  You can also write [1,2,3,for(.....),
[1,2,3,for(...),5,6,if (condition) 19].

On Sat, May 7, 2022 at 1:08 PM Joe Weinpert joe.weinpert@gmail.com wrote:

Seems to be working.  Thanks!  What is the purpose of the brackets in openSCAD?

On Sat, May 7, 2022 at 12:42 PM Hans L thehans@gmail.com wrote:

You would do something like this, if I'm understanding your problem correctly:
pathArray = [for(element = svgArray) svgPoints(element)];

On Sat, May 7, 2022 at 11:28 AM Joe Weinpert joe.weinpert@gmail.com wrote:

Having a problem understanding the "for" function.  Heck, I'm having a problem understanding programs where all the variables are calculated at compile time and not runtime.

I have an array of 11 svg strings named "svgArray" indexed as 0-10.  This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l 4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the pathbuilder library function svgPoints().  The above string is converted into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857], [67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named "pathArray" to match each one in the "svgArray".  This means I have to loop through the "svgArray", convert the current one to a point array using the svgPoints() function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays throughout the rest of the scad program?

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

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

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

JW
Joe Weinpert
Sat, May 7, 2022 5:25 PM

So, what you are saying is the brackets with for are only used when
making an array (list) of something, correct?

On Sat, May 7, 2022 at 1:18 PM Adrian Mariano avm4@cornell.edu wrote:

The brackets make the item a list, just like in the example [1,2,3].
Without the brackets it's just like a bunch of numbers, like writing
1,2,3.  It's the same with for.  You can also write [1,2,3,for(.....),
[1,2,3,for(...),5,6,if (condition) 19].

On Sat, May 7, 2022 at 1:08 PM Joe Weinpert joe.weinpert@gmail.com
wrote:

Seems to be working.  Thanks!  What is the purpose of the brackets in

On Sat, May 7, 2022 at 12:42 PM Hans L thehans@gmail.com wrote:

You would do something like this, if I'm understanding your problem

correctly:

`````` pathArray = [for(element = svgArray) svgPoints(element)];
``````

On Sat, May 7, 2022 at 11:28 AM Joe Weinpert joe.weinpert@gmail.com

wrote:

Having a problem understanding the "for" function.  Heck, I'm having

a problem understanding programs where all the variables are calculated at
compile time and not runtime.

I have an array of 11 svg strings named "svgArray" indexed as 0-10.

This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l

4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the pathbuilder

library function svgPoints().  The above string is converted into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634],

[59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327,
12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659],
[60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915,
8.70857], [67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named

"pathArray" to match each one in the "svgArray".  This means I have to loop
through the "svgArray", convert the current one to a point array using the
svgPoints() function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays throughout

the rest of the scad program?

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

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

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

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

AM
Sat, May 7, 2022 7:26 PM

Yes, the brackets are used only when making a list, though lists of
numbers not in brackets are not valid by themselves, so you can't just
remove the brackets.  The other possible use of for() is as a module,
to make geometry, and it doesn't use brackets.

On Sat, May 7, 2022 at 1:25 PM Joe Weinpert joe.weinpert@gmail.com wrote:

So, what you are saying is the brackets with for are only used when making an array (list) of something, correct?

On Sat, May 7, 2022 at 1:18 PM Adrian Mariano avm4@cornell.edu wrote:

The brackets make the item a list, just like in the example [1,2,3].
Without the brackets it's just like a bunch of numbers, like writing
1,2,3.  It's the same with for.  You can also write [1,2,3,for(.....),
[1,2,3,for(...),5,6,if (condition) 19].

On Sat, May 7, 2022 at 1:08 PM Joe Weinpert joe.weinpert@gmail.com wrote:

Seems to be working.  Thanks!  What is the purpose of the brackets in openSCAD?

On Sat, May 7, 2022 at 12:42 PM Hans L thehans@gmail.com wrote:

You would do something like this, if I'm understanding your problem correctly:
pathArray = [for(element = svgArray) svgPoints(element)];

On Sat, May 7, 2022 at 11:28 AM Joe Weinpert joe.weinpert@gmail.com wrote:

Having a problem understanding the "for" function.  Heck, I'm having a problem understanding programs where all the variables are calculated at compile time and not runtime.

I have an array of 11 svg strings named "svgArray" indexed as 0-10.  This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l 4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the pathbuilder library function svgPoints().  The above string is converted into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857], [67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named "pathArray" to match each one in the "svgArray".  This means I have to loop through the "svgArray", convert the current one to a point array using the svgPoints() function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays throughout the rest of the scad program?

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

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

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

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

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

HL
Hans L
Sat, May 7, 2022 7:26 PM

Using "for" inside brackets is a form of list comprehension:
In that case "for" is part of an expression.

Outside of brackets, "for" is also defined, but in that case it is a
builtin module (it can generate geometry but does not return a
value)

Neither are technically "functions", just to be clear (since you
called it such in your original post)

On Sat, May 7, 2022 at 12:25 PM Joe Weinpert joe.weinpert@gmail.com wrote:

So, what you are saying is the brackets with for are only used when making an array (list) of something, correct?

On Sat, May 7, 2022 at 1:18 PM Adrian Mariano avm4@cornell.edu wrote:

The brackets make the item a list, just like in the example [1,2,3].
Without the brackets it's just like a bunch of numbers, like writing
1,2,3.  It's the same with for.  You can also write [1,2,3,for(.....),
[1,2,3,for(...),5,6,if (condition) 19].

On Sat, May 7, 2022 at 1:08 PM Joe Weinpert joe.weinpert@gmail.com wrote:

Seems to be working.  Thanks!  What is the purpose of the brackets in openSCAD?

On Sat, May 7, 2022 at 12:42 PM Hans L thehans@gmail.com wrote:

You would do something like this, if I'm understanding your problem correctly:
pathArray = [for(element = svgArray) svgPoints(element)];

On Sat, May 7, 2022 at 11:28 AM Joe Weinpert joe.weinpert@gmail.com wrote:

Having a problem understanding the "for" function.  Heck, I'm having a problem understanding programs where all the variables are calculated at compile time and not runtime.

I have an array of 11 svg strings named "svgArray" indexed as 0-10.  This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l 4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the pathbuilder library function svgPoints().  The above string is converted into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857], [67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named "pathArray" to match each one in the "svgArray".  This means I have to loop through the "svgArray", convert the current one to a point array using the svgPoints() function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays throughout the rest of the scad program?

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

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

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

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

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

JW
Joe Weinpert
Sun, May 8, 2022 4:33 PM

Yep ... I gotta get used to the fact that in openSCAD the *for *loop is not
a function.

On Sat, May 7, 2022 at 3:27 PM Hans L thehans@gmail.com wrote:

Using "for" inside brackets is a form of list comprehension:
In that case "for" is part of an expression.

Outside of brackets, "for" is also defined, but in that case it is a
builtin module (it can generate geometry but does not return a
value)

Neither are technically "functions", just to be clear (since you
called it such in your original post)

On Sat, May 7, 2022 at 12:25 PM Joe Weinpert joe.weinpert@gmail.com
wrote:

So, what you are saying is the brackets with for are only used when

making an array (list) of something, correct?

On Sat, May 7, 2022 at 1:18 PM Adrian Mariano avm4@cornell.edu wrote:

The brackets make the item a list, just like in the example [1,2,3].
Without the brackets it's just like a bunch of numbers, like writing
1,2,3.  It's the same with for.  You can also write [1,2,3,for(.....),
[1,2,3,for(...),5,6,if (condition) 19].

On Sat, May 7, 2022 at 1:08 PM Joe Weinpert joe.weinpert@gmail.com

wrote:

Seems to be working.  Thanks!  What is the purpose of the brackets

On Sat, May 7, 2022 at 12:42 PM Hans L thehans@gmail.com wrote:

You would do something like this, if I'm understanding your problem

correctly:

`````` pathArray = [for(element = svgArray) svgPoints(element)];
``````

On Sat, May 7, 2022 at 11:28 AM Joe Weinpert joe.weinpert@gmail.com

wrote:

Having a problem understanding the "for" function.  Heck, I'm

having a problem understanding programs where all the variables are
calculated at compile time and not runtime.

I have an array of 11 svg strings named "svgArray" indexed as

0-10.  This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l

4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the

pathbuilder library function svgPoints().  The above string is converted
into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634],

[59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327,
12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659],
[60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915,
8.70857], [67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named

"pathArray" to match each one in the "svgArray".  This means I have to loop
through the "svgArray", convert the current one to a point array using the
svgPoints() function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays

throughout the rest of the scad program?

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

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

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

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

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

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

HL
Hans L
Sun, May 8, 2022 8:31 PM

It's not a function in most languages.

On Sun, May 8, 2022 at 11:34 AM Joe Weinpert joe.weinpert@gmail.com wrote:

Yep ... I gotta get used to the fact that in openSCAD the for loop is not a function.

On Sat, May 7, 2022 at 3:27 PM Hans L thehans@gmail.com wrote:

Using "for" inside brackets is a form of list comprehension:
In that case "for" is part of an expression.

Outside of brackets, "for" is also defined, but in that case it is a
builtin module (it can generate geometry but does not return a
value)

Neither are technically "functions", just to be clear (since you
called it such in your original post)

On Sat, May 7, 2022 at 12:25 PM Joe Weinpert joe.weinpert@gmail.com wrote:

So, what you are saying is the brackets with for are only used when making an array (list) of something, correct?

On Sat, May 7, 2022 at 1:18 PM Adrian Mariano avm4@cornell.edu wrote:

The brackets make the item a list, just like in the example [1,2,3].
Without the brackets it's just like a bunch of numbers, like writing
1,2,3.  It's the same with for.  You can also write [1,2,3,for(.....),
[1,2,3,for(...),5,6,if (condition) 19].

On Sat, May 7, 2022 at 1:08 PM Joe Weinpert joe.weinpert@gmail.com wrote:

Seems to be working.  Thanks!  What is the purpose of the brackets in openSCAD?

On Sat, May 7, 2022 at 12:42 PM Hans L thehans@gmail.com wrote:

You would do something like this, if I'm understanding your problem correctly:
pathArray = [for(element = svgArray) svgPoints(element)];

On Sat, May 7, 2022 at 11:28 AM Joe Weinpert joe.weinpert@gmail.com wrote:

Having a problem understanding the "for" function.  Heck, I'm having a problem understanding programs where all the variables are calculated at compile time and not runtime.

I have an array of 11 svg strings named "svgArray" indexed as 0-10.  This one is from index 4:

["m 57.694281,5.80572 q 2.90284,7.25713 2.90284,8.70856 h 2.54 l 4.35434,-0.36285 v -5.44286 l -0.36288,-1.81429 h -2.54001 z"]

svg strings can be converted to a point array using the pathbuilder library function svgPoints().  The above string is converted into this:

[[57.6943, 5.80572], [58.2458, 7.19909], [58.7393, 8.47634], [59.1747, 9.63748], [59.5521, 10.6825], [59.8714, 11.6114], [60.1327, 12.4242], [60.3359, 13.1209], [60.481, 13.7015], [60.5681, 14.1659], [60.5971, 14.5143], [63.1371, 14.5143], [67.4915, 14.1514], [67.4915, 8.70857], [67.1286, 6.89428], [64.5886, 6.89428]]

But ...

I would like to create an indexed array of the points named "pathArray" to match each one in the "svgArray".  This means I have to loop through the "svgArray", convert the current one to a point array using the svgPoints() function then append it to the "pathArray" being generated.

How can I do that so I can use the array of point arrays throughout the rest of the scad program?

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

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

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

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