discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

for() loop iteration limitation & list comprehensions

DC
David Coneff
Wed, Mar 8, 2017 11:47 PM

I have 16 GB of RAM, a 1 TB SSD, and a quad-core i7 in my laptop. The
unfortunate thing about most software is that it is written to keep
programs in check for lower spec systems, but frequently doesn't have the
option to disable those limits or up them when you do have better hardware.
I think it is perfectly reasonable to have a default limit of 10,000 since
not everyone has the setup I do, it'd just be nice to have an option to
change it if I want to do something dumb on purpose :).

On Wed, Mar 8, 2017 at 4:36 PM, nop head nop.head@gmail.com wrote:

for(x = [0:99], y = [0:99])
translate([x * 10, y * 10, 0])
sphere(1);

Takes 1 hour 18 minutes on my system and uses 2.6GB of memory. So perhaps
10K is a bit low, but not much before it would bring my system to its knees
as Windows doesn't handle running out of memory very well.

On 8 March 2017 at 23:02, Ronaldo rcmpersiano@gmail.com wrote:

davidconeff wrote

In the case of, say, 10000
cubes lying on a unit sphere evenly-spaced grid, CGAL doesn't have as

much

of a problem although it does take a while to render.

Are you sure of that? As far as I know neither OpenSCAD nor CGAL use
bounding boxes.

--
View this message in context: http://forum.openscad.org/for-
loop-iteration-limitation-list-comprehensions-tp20806p20813.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

I have 16 GB of RAM, a 1 TB SSD, and a quad-core i7 in my laptop. The unfortunate thing about most software is that it is written to keep programs in check for lower spec systems, but frequently doesn't have the option to disable those limits or up them when you do have better hardware. I think it is perfectly reasonable to have a default limit of 10,000 since not everyone has the setup I do, it'd just be nice to have an option to change it if I want to do something dumb on purpose :). On Wed, Mar 8, 2017 at 4:36 PM, nop head <nop.head@gmail.com> wrote: > for(x = [0:99], y = [0:99]) > translate([x * 10, y * 10, 0]) > sphere(1); > > Takes 1 hour 18 minutes on my system and uses 2.6GB of memory. So perhaps > 10K is a bit low, but not much before it would bring my system to its knees > as Windows doesn't handle running out of memory very well. > > > > On 8 March 2017 at 23:02, Ronaldo <rcmpersiano@gmail.com> wrote: > >> davidconeff wrote >> > In the case of, say, 10000 >> > cubes lying on a unit sphere evenly-spaced grid, CGAL doesn't have as >> much >> > of a problem although it does take a while to render. >> >> Are you sure of that? As far as I know neither OpenSCAD nor CGAL use >> bounding boxes. >> >> >> >> -- >> View this message in context: http://forum.openscad.org/for- >> loop-iteration-limitation-list-comprehensions-tp20806p20813.html >> Sent from the OpenSCAD mailing list archive at Nabble.com. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
DC
David Coneff
Wed, Mar 8, 2017 11:48 PM

Actually, just realized 24 GB of RAM. 16 GB is available after I have a
bunch of programs running and a few different OpenSCAD instances.

On Wed, Mar 8, 2017 at 4:47 PM, David Coneff david.coneff@gmail.com wrote:

I have 16 GB of RAM, a 1 TB SSD, and a quad-core i7 in my laptop. The
unfortunate thing about most software is that it is written to keep
programs in check for lower spec systems, but frequently doesn't have the
option to disable those limits or up them when you do have better hardware.
I think it is perfectly reasonable to have a default limit of 10,000 since
not everyone has the setup I do, it'd just be nice to have an option to
change it if I want to do something dumb on purpose :).

On Wed, Mar 8, 2017 at 4:36 PM, nop head nop.head@gmail.com wrote:

for(x = [0:99], y = [0:99])
translate([x * 10, y * 10, 0])
sphere(1);

Takes 1 hour 18 minutes on my system and uses 2.6GB of memory. So perhaps
10K is a bit low, but not much before it would bring my system to its knees
as Windows doesn't handle running out of memory very well.

On 8 March 2017 at 23:02, Ronaldo rcmpersiano@gmail.com wrote:

davidconeff wrote

In the case of, say, 10000
cubes lying on a unit sphere evenly-spaced grid, CGAL doesn't have as

much

of a problem although it does take a while to render.

Are you sure of that? As far as I know neither OpenSCAD nor CGAL use
bounding boxes.

--
View this message in context: http://forum.openscad.org/for-
loop-iteration-limitation-list-comprehensions-tp20806p20813.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

Actually, just realized 24 GB of RAM. 16 GB is available after I have a bunch of programs running and a few different OpenSCAD instances. On Wed, Mar 8, 2017 at 4:47 PM, David Coneff <david.coneff@gmail.com> wrote: > I have 16 GB of RAM, a 1 TB SSD, and a quad-core i7 in my laptop. The > unfortunate thing about most software is that it is written to keep > programs in check for lower spec systems, but frequently doesn't have the > option to disable those limits or up them when you do have better hardware. > I think it is perfectly reasonable to have a default limit of 10,000 since > not everyone has the setup I do, it'd just be nice to have an option to > change it if I want to do something dumb on purpose :). > > On Wed, Mar 8, 2017 at 4:36 PM, nop head <nop.head@gmail.com> wrote: > >> for(x = [0:99], y = [0:99]) >> translate([x * 10, y * 10, 0]) >> sphere(1); >> >> Takes 1 hour 18 minutes on my system and uses 2.6GB of memory. So perhaps >> 10K is a bit low, but not much before it would bring my system to its knees >> as Windows doesn't handle running out of memory very well. >> >> >> >> On 8 March 2017 at 23:02, Ronaldo <rcmpersiano@gmail.com> wrote: >> >>> davidconeff wrote >>> > In the case of, say, 10000 >>> > cubes lying on a unit sphere evenly-spaced grid, CGAL doesn't have as >>> much >>> > of a problem although it does take a while to render. >>> >>> Are you sure of that? As far as I know neither OpenSCAD nor CGAL use >>> bounding boxes. >>> >>> >>> >>> -- >>> View this message in context: http://forum.openscad.org/for- >>> loop-iteration-limitation-list-comprehensions-tp20806p20813.html >>> Sent from the OpenSCAD mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >
NH
nop head
Wed, Mar 8, 2017 11:54 PM

CGAL is extremely slow when there are a large number of non overlapping
facets. It gets even slower if they do overlap but it certainly doesn't
skip the easy cases.

On 8 March 2017 at 23:47, David Coneff david.coneff@gmail.com wrote:

I have 16 GB of RAM, a 1 TB SSD, and a quad-core i7 in my laptop. The
unfortunate thing about most software is that it is written to keep
programs in check for lower spec systems, but frequently doesn't have the
option to disable those limits or up them when you do have better hardware.
I think it is perfectly reasonable to have a default limit of 10,000 since
not everyone has the setup I do, it'd just be nice to have an option to
change it if I want to do something dumb on purpose :).

On Wed, Mar 8, 2017 at 4:36 PM, nop head nop.head@gmail.com wrote:

for(x = [0:99], y = [0:99])
translate([x * 10, y * 10, 0])
sphere(1);

Takes 1 hour 18 minutes on my system and uses 2.6GB of memory. So perhaps
10K is a bit low, but not much before it would bring my system to its knees
as Windows doesn't handle running out of memory very well.

On 8 March 2017 at 23:02, Ronaldo rcmpersiano@gmail.com wrote:

davidconeff wrote

In the case of, say, 10000
cubes lying on a unit sphere evenly-spaced grid, CGAL doesn't have as

much

of a problem although it does take a while to render.

Are you sure of that? As far as I know neither OpenSCAD nor CGAL use
bounding boxes.

--
View this message in context: http://forum.openscad.org/for-
loop-iteration-limitation-list-comprehensions-tp20806p20813.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

CGAL is extremely slow when there are a large number of non overlapping facets. It gets even slower if they do overlap but it certainly doesn't skip the easy cases. On 8 March 2017 at 23:47, David Coneff <david.coneff@gmail.com> wrote: > I have 16 GB of RAM, a 1 TB SSD, and a quad-core i7 in my laptop. The > unfortunate thing about most software is that it is written to keep > programs in check for lower spec systems, but frequently doesn't have the > option to disable those limits or up them when you do have better hardware. > I think it is perfectly reasonable to have a default limit of 10,000 since > not everyone has the setup I do, it'd just be nice to have an option to > change it if I want to do something dumb on purpose :). > > On Wed, Mar 8, 2017 at 4:36 PM, nop head <nop.head@gmail.com> wrote: > >> for(x = [0:99], y = [0:99]) >> translate([x * 10, y * 10, 0]) >> sphere(1); >> >> Takes 1 hour 18 minutes on my system and uses 2.6GB of memory. So perhaps >> 10K is a bit low, but not much before it would bring my system to its knees >> as Windows doesn't handle running out of memory very well. >> >> >> >> On 8 March 2017 at 23:02, Ronaldo <rcmpersiano@gmail.com> wrote: >> >>> davidconeff wrote >>> > In the case of, say, 10000 >>> > cubes lying on a unit sphere evenly-spaced grid, CGAL doesn't have as >>> much >>> > of a problem although it does take a while to render. >>> >>> Are you sure of that? As far as I know neither OpenSCAD nor CGAL use >>> bounding boxes. >>> >>> >>> >>> -- >>> View this message in context: http://forum.openscad.org/for- >>> loop-iteration-limitation-list-comprehensions-tp20806p20813.html >>> Sent from the OpenSCAD mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
DC
David Coneff
Thu, Mar 9, 2017 1:31 AM

I agree it does get slow. Just that it won't necessarily seize up or throw
an error simply because there are a bunch. But that's to be expected for
any model of sufficient complexity.

On Wed, Mar 8, 2017 at 4:54 PM, nop head nop.head@gmail.com wrote:

CGAL is extremely slow when there are a large number of non overlapping
facets. It gets even slower if they do overlap but it certainly doesn't
skip the easy cases.

On 8 March 2017 at 23:47, David Coneff david.coneff@gmail.com wrote:

I have 16 GB of RAM, a 1 TB SSD, and a quad-core i7 in my laptop. The
unfortunate thing about most software is that it is written to keep
programs in check for lower spec systems, but frequently doesn't have the
option to disable those limits or up them when you do have better hardware.
I think it is perfectly reasonable to have a default limit of 10,000 since
not everyone has the setup I do, it'd just be nice to have an option to
change it if I want to do something dumb on purpose :).

On Wed, Mar 8, 2017 at 4:36 PM, nop head nop.head@gmail.com wrote:

for(x = [0:99], y = [0:99])
translate([x * 10, y * 10, 0])
sphere(1);

Takes 1 hour 18 minutes on my system and uses 2.6GB of memory. So
perhaps 10K is a bit low, but not much before it would bring my system to
its knees as Windows doesn't handle running out of memory very well.

On 8 March 2017 at 23:02, Ronaldo rcmpersiano@gmail.com wrote:

davidconeff wrote

In the case of, say, 10000
cubes lying on a unit sphere evenly-spaced grid, CGAL doesn't have as

much

of a problem although it does take a while to render.

Are you sure of that? As far as I know neither OpenSCAD nor CGAL use
bounding boxes.

--
View this message in context: http://forum.openscad.org/for-
loop-iteration-limitation-list-comprehensions-tp20806p20813.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

I agree it does get slow. Just that it won't necessarily seize up or throw an error simply because there are a bunch. But that's to be expected for any model of sufficient complexity. On Wed, Mar 8, 2017 at 4:54 PM, nop head <nop.head@gmail.com> wrote: > CGAL is extremely slow when there are a large number of non overlapping > facets. It gets even slower if they do overlap but it certainly doesn't > skip the easy cases. > > > On 8 March 2017 at 23:47, David Coneff <david.coneff@gmail.com> wrote: > >> I have 16 GB of RAM, a 1 TB SSD, and a quad-core i7 in my laptop. The >> unfortunate thing about most software is that it is written to keep >> programs in check for lower spec systems, but frequently doesn't have the >> option to disable those limits or up them when you do have better hardware. >> I think it is perfectly reasonable to have a default limit of 10,000 since >> not everyone has the setup I do, it'd just be nice to have an option to >> change it if I want to do something dumb on purpose :). >> >> On Wed, Mar 8, 2017 at 4:36 PM, nop head <nop.head@gmail.com> wrote: >> >>> for(x = [0:99], y = [0:99]) >>> translate([x * 10, y * 10, 0]) >>> sphere(1); >>> >>> Takes 1 hour 18 minutes on my system and uses 2.6GB of memory. So >>> perhaps 10K is a bit low, but not much before it would bring my system to >>> its knees as Windows doesn't handle running out of memory very well. >>> >>> >>> >>> On 8 March 2017 at 23:02, Ronaldo <rcmpersiano@gmail.com> wrote: >>> >>>> davidconeff wrote >>>> > In the case of, say, 10000 >>>> > cubes lying on a unit sphere evenly-spaced grid, CGAL doesn't have as >>>> much >>>> > of a problem although it does take a while to render. >>>> >>>> Are you sure of that? As far as I know neither OpenSCAD nor CGAL use >>>> bounding boxes. >>>> >>>> >>>> >>>> -- >>>> View this message in context: http://forum.openscad.org/for- >>>> loop-iteration-limitation-list-comprehensions-tp20806p20813.html >>>> Sent from the OpenSCAD mailing list archive at Nabble.com. >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> Discuss@lists.openscad.org >>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >>> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
M
MichaelAtOz
Thu, Mar 9, 2017 1:44 AM

I've had some things which rendered in 24+ hours.
(slowed by Windows swapping to SSD)
If someone wants to make some normally unreasonable thing, it is their time
they are potentially wasting.

I think a limit should be an advanced option, AND, it should probably apply
to the other cases Ronald highlighted too.


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/for-loop-iteration-limitation-list-comprehensions-tp20806p20820.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I've had some things which rendered in 24+ hours. (slowed by Windows swapping to SSD) If someone wants to make some normally unreasonable thing, it is their time they are potentially wasting. I think a limit should be an advanced option, AND, it should probably apply to the other cases Ronald highlighted too. ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/for-loop-iteration-limitation-list-comprehensions-tp20806p20820.html Sent from the OpenSCAD mailing list archive at Nabble.com.
RP
Ronaldo Persiano
Thu, Mar 9, 2017 3:01 AM

I see the limit of ranges, lists, whatever as a constraint. It may seem
reasonable to avoid a long unwanted run by a beginner. But it may be a
bottleneck for many serious work. So, David proposal that the limit may be
extended by the user is a sensible one.

It may seem reasonable to extend the guardianship to lists. But a
bi-dimensional matrix of 100x100 has 10000 elements. Should it be
prohibited? I have implemented some f-rep modelling methods in OpenSCAD.
Often that system build tri-dimensional matrices greater than 100x100x100
and build lists of triangles with more than 20000 elements. Any organic
model will have this sort of size. Should all this be forbidden because
this is not the intended application?

OpenSCAD is a powerful tool and should not be restricted to the beginner
that builds models with a handful of cubes. Or it will be no more than a
hammer, and worst, a hammer toy.

I see the limit of ranges, lists, whatever as a constraint. It may seem reasonable to avoid a long unwanted run by a beginner. But it may be a bottleneck for many serious work. So, David proposal that the limit may be extended by the user is a sensible one. It may seem reasonable to extend the guardianship to lists. But a bi-dimensional matrix of 100x100 has 10000 elements. Should it be prohibited? I have implemented some f-rep modelling methods in OpenSCAD. Often that system build tri-dimensional matrices greater than 100x100x100 and build lists of triangles with more than 20000 elements. Any organic model will have this sort of size. Should all this be forbidden because this is not the intended application? OpenSCAD is a powerful tool and should not be restricted to the beginner that builds models with a handful of cubes. Or it will be no more than a hammer, and worst, a hammer toy.
DC
David Coneff
Thu, Mar 9, 2017 3:22 AM

That's my general feeling Ronaldo, I started playing with OpenSCAD because
it is open-source and free, has a wide user base in the 3D printing
community, and readily translates models on a computer to valid STL files
that can be printed without much fuss if the appropriate level of detail is
applied to the CGAL render. There's no reason it can't be used for serious
work, it just has a less developed UI than the average piece of commercial
software. For my purposes that is fine since the work I'm doing with is
generative/algorithmic and not stuff that could be done by hand with a
cursor in a well-developed GUI. It's just the minor limitations that I run
into that are occasionally annoying, like this 10,000 element limitation.
It's reasonable to prevent beginners from blowing up the program and
thinking it is unstable on their mediocre computers (it's remarkably solid
for open-source!), and to nudge you in the direction of using more
sophisticated language features where appropriate (e.g., list
comprehensions for purely mathematical stuff), but there are plenty of
situations where that hard-coded limit is just an unnecessary obstacle.
Sometimes you need to be able to use an inefficient script, see if the
concept works, and refactor later.

On Wed, Mar 8, 2017 at 8:01 PM, Ronaldo Persiano rcmpersiano@gmail.com
wrote:

I see the limit of ranges, lists, whatever as a constraint. It may seem
reasonable to avoid a long unwanted run by a beginner. But it may be a
bottleneck for many serious work. So, David proposal that the limit may be
extended by the user is a sensible one.

It may seem reasonable to extend the guardianship to lists. But a
bi-dimensional matrix of 100x100 has 10000 elements. Should it be
prohibited? I have implemented some f-rep modelling methods in OpenSCAD.
Often that system build tri-dimensional matrices greater than 100x100x100
and build lists of triangles with more than 20000 elements. Any organic
model will have this sort of size. Should all this be forbidden because
this is not the intended application?

OpenSCAD is a powerful tool and should not be restricted to the beginner
that builds models with a handful of cubes. Or it will be no more than a
hammer, and worst, a hammer toy.


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

That's my general feeling Ronaldo, I started playing with OpenSCAD because it is open-source and free, has a wide user base in the 3D printing community, and readily translates models on a computer to valid STL files that can be printed without much fuss if the appropriate level of detail is applied to the CGAL render. There's no reason it can't be used for serious work, it just has a less developed UI than the average piece of commercial software. For my purposes that is fine since the work I'm doing with is generative/algorithmic and not stuff that could be done by hand with a cursor in a well-developed GUI. It's just the minor limitations that I run into that are occasionally annoying, like this 10,000 element limitation. It's reasonable to prevent beginners from blowing up the program and thinking it is unstable on their mediocre computers (it's remarkably solid for open-source!), and to nudge you in the direction of using more sophisticated language features where appropriate (e.g., list comprehensions for purely mathematical stuff), but there are plenty of situations where that hard-coded limit is just an unnecessary obstacle. Sometimes you need to be able to use an inefficient script, see if the concept works, and refactor later. On Wed, Mar 8, 2017 at 8:01 PM, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > I see the limit of ranges, lists, whatever as a constraint. It may seem > reasonable to avoid a long unwanted run by a beginner. But it may be a > bottleneck for many serious work. So, David proposal that the limit may be > extended by the user is a sensible one. > > It may seem reasonable to extend the guardianship to lists. But a > bi-dimensional matrix of 100x100 has 10000 elements. Should it be > prohibited? I have implemented some f-rep modelling methods in OpenSCAD. > Often that system build tri-dimensional matrices greater than 100x100x100 > and build lists of triangles with more than 20000 elements. Any organic > model will have this sort of size. Should all this be forbidden because > this is not the intended application? > > OpenSCAD is a powerful tool and should not be restricted to the beginner > that builds models with a handful of cubes. Or it will be no more than a > hammer, and worst, a hammer toy. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
MK
Marius Kintel
Thu, Mar 9, 2017 3:49 AM

I agree that there are valid workflows outside our hardcoded limits.
Does anyone want to take a shot at refactoring the limit system?
I’d see a few relatively isolated steps:
o Make it configurable (using our config file)
o Make it adjustable using GUI/Preferences
o Detect limit situations and offer helpful dialogs offering users to cancel / ignore limit once / Never ask me again

The primary challenge is that once we start certain operations, we cannot cancel. When we run our own code, this is fixable, but if we hit a non-cancellable entry point to a 3rd party library it gets trickier (e.g. CGAL).

-Marius

I agree that there are valid workflows outside our hardcoded limits. Does anyone want to take a shot at refactoring the limit system? I’d see a few relatively isolated steps: o Make it configurable (using our config file) o Make it adjustable using GUI/Preferences o Detect limit situations and offer helpful dialogs offering users to cancel / ignore limit once / Never ask me again The primary challenge is that once we start certain operations, we cannot cancel. When we run our own code, this is fixable, but if we hit a non-cancellable entry point to a 3rd party library it gets trickier (e.g. CGAL). -Marius
DC
David Coneff
Thu, Mar 9, 2017 4:41 AM

Ronaldo,

Since you knew the for() syntax that bypasses the 10,000 element
limitation, I was wondering if you might also know the solution to this:

Say I have a list of the form:

[[x,y,z],[x2,y2,z2],....]

How would I make a for() loop that performs an action using the (i)-th and
(i+1)th elements? Normally I would use the iterator variable, but the
syntax that bypasses the 10,000 range limit doesn't have "access" to an
iterator variable.

simple example of what I would normally do:

points = [[1,1,1],[2,2,2],[3,3,3]]
for(i = [0:1:len(points-2)]){
translate([points[i][0],points[i+1][1],0])cube(1);
}

On Wed, Mar 8, 2017 at 3:54 PM, Ronaldo Persiano rcmpersiano@gmail.com
wrote:

David,

The main aspect to understand is that there is a for limit just for ranges.

If you don't use range in a for, there is no limit.

p = rands(0,1,1000000); // p is a list of 1000000 elements
for(pi=p){ // there is no range here
if(pi<1e-6) echo(pi=pi);
}

Or if all your ranges have less than 10000 elements, you will not get an
error message.

// a very long for with ranges
for(i=[0:999], j=[0:999], k=1000*i+j){
if(k<10 ||  k> 999990) echo(k=k);
}

The same happens with for in list comprehension:

// short lists filtered from a long lists
q = [for(pi=p) if(pi<1e-6) pi];
s = [for(i=[0:999], j=[0:999], k=1000*i+j) if(k<len(p)-1 && p[k]<1e-6 )
p[k] ];
echo(q=q);
echo(s=s);


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

Ronaldo, Since you knew the for() syntax that bypasses the 10,000 element limitation, I was wondering if you might also know the solution to this: Say I have a list of the form: [[x,y,z],[x2,y2,z2],....] How would I make a for() loop that performs an action using the (i)-th and (i+1)th elements? Normally I would use the iterator variable, but the syntax that bypasses the 10,000 range limit doesn't have "access" to an iterator variable. simple example of what I would normally do: points = [[1,1,1],[2,2,2],[3,3,3]] for(i = [0:1:len(points-2)]){ translate([points[i][0],points[i+1][1],0])cube(1); } On Wed, Mar 8, 2017 at 3:54 PM, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > David, > > The main aspect to understand is that there is a for limit just for ranges. > > If you don't use range in a for, there is no limit. > > p = rands(0,1,1000000); // p is a list of 1000000 elements > for(pi=p){ // there is no range here > if(pi<1e-6) echo(pi=pi); > } > > Or if all your ranges have less than 10000 elements, you will not get an > error message. > > // a very long for with ranges > for(i=[0:999], j=[0:999], k=1000*i+j){ > if(k<10 || k> 999990) echo(k=k); > } > > The same happens with for in list comprehension: > > // short lists filtered from a long lists > q = [for(pi=p) if(pi<1e-6) pi]; > s = [for(i=[0:999], j=[0:999], k=1000*i+j) if(k<len(p)-1 && p[k]<1e-6 ) > p[k] ]; > echo(q=q); > echo(s=s); > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
NH
nop head
Thu, Mar 9, 2017 10:17 AM

I think this a work around that will allow a for loop of 10,000,000

module for_n(n) {
thousands = floor(n / 1000);
remainder = n % 1000;
if(thousands)
for(a = [0 : thousands - 1], b = [0 : 999], $i = a * 1000 + b)
children();
if(remainder)
for(a = [0 : remainder - 1], $i = thousands * 1000 + a)
children();
}

for_n(1002)
echo($i);

Note that it counts from 0 to n-1

On 9 March 2017 at 04:41, David Coneff david.coneff@gmail.com wrote:

Ronaldo,

Since you knew the for() syntax that bypasses the 10,000 element
limitation, I was wondering if you might also know the solution to this:

Say I have a list of the form:

[[x,y,z],[x2,y2,z2],....]

How would I make a for() loop that performs an action using the (i)-th and
(i+1)th elements? Normally I would use the iterator variable, but the
syntax that bypasses the 10,000 range limit doesn't have "access" to an
iterator variable.

simple example of what I would normally do:

points = [[1,1,1],[2,2,2],[3,3,3]]
for(i = [0:1:len(points-2)]){
translate([points[i][0],points[i+1][1],0])cube(1);
}

On Wed, Mar 8, 2017 at 3:54 PM, Ronaldo Persiano rcmpersiano@gmail.com
wrote:

David,

The main aspect to understand is that there is a for limit just for
ranges.

If you don't use range in a for, there is no limit.

p = rands(0,1,1000000); // p is a list of 1000000 elements
for(pi=p){ // there is no range here
if(pi<1e-6) echo(pi=pi);
}

Or if all your ranges have less than 10000 elements, you will not get an
error message.

// a very long for with ranges
for(i=[0:999], j=[0:999], k=1000*i+j){
if(k<10 ||  k> 999990) echo(k=k);
}

The same happens with for in list comprehension:

// short lists filtered from a long lists
q = [for(pi=p) if(pi<1e-6) pi];
s = [for(i=[0:999], j=[0:999], k=1000*i+j) if(k<len(p)-1 && p[k]<1e-6 )
p[k] ];
echo(q=q);
echo(s=s);


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

I think this a work around that will allow a for loop of 10,000,000 module for_n(n) { thousands = floor(n / 1000); remainder = n % 1000; if(thousands) for(a = [0 : thousands - 1], b = [0 : 999], $i = a * 1000 + b) children(); if(remainder) for(a = [0 : remainder - 1], $i = thousands * 1000 + a) children(); } for_n(1002) echo($i); Note that it counts from 0 to n-1 On 9 March 2017 at 04:41, David Coneff <david.coneff@gmail.com> wrote: > Ronaldo, > > Since you knew the for() syntax that bypasses the 10,000 element > limitation, I was wondering if you might also know the solution to this: > > Say I have a list of the form: > > [[x,y,z],[x2,y2,z2],....] > > How would I make a for() loop that performs an action using the (i)-th and > (i+1)th elements? Normally I would use the iterator variable, but the > syntax that bypasses the 10,000 range limit doesn't have "access" to an > iterator variable. > > simple example of what I would normally do: > > points = [[1,1,1],[2,2,2],[3,3,3]] > for(i = [0:1:len(points-2)]){ > translate([points[i][0],points[i+1][1],0])cube(1); > } > > On Wed, Mar 8, 2017 at 3:54 PM, Ronaldo Persiano <rcmpersiano@gmail.com> > wrote: > >> David, >> >> The main aspect to understand is that there is a for limit just for >> ranges. >> >> If you don't use range in a for, there is no limit. >> >> p = rands(0,1,1000000); // p is a list of 1000000 elements >> for(pi=p){ // there is no range here >> if(pi<1e-6) echo(pi=pi); >> } >> >> Or if all your ranges have less than 10000 elements, you will not get an >> error message. >> >> // a very long for with ranges >> for(i=[0:999], j=[0:999], k=1000*i+j){ >> if(k<10 || k> 999990) echo(k=k); >> } >> >> The same happens with for in list comprehension: >> >> // short lists filtered from a long lists >> q = [for(pi=p) if(pi<1e-6) pi]; >> s = [for(i=[0:999], j=[0:999], k=1000*i+j) if(k<len(p)-1 && p[k]<1e-6 ) >> p[k] ]; >> echo(q=q); >> echo(s=s); >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >