[OpenSCAD] limit on range in for statement

nop head nop.head at gmail.com
Tue Oct 15 05:27:38 EDT 2019


Another workaround is to use a nested loop.

This is hardcoded in OpenSCAD in about half a dozen places. I should either
be a preference of a much higher value. 10000 elements in a list is nothing
on today's hardware. 10000 3D CSG operations on the other hand will bring
CGAL to its knees.

On Tue, 15 Oct 2019 at 10:07, kitwallace <kit.wallace at gmail.com> wrote:

> I'm bumping into another limit - for long lists of points the following
> fails
> with
>
> WARNING: Bad range parameter in for statement: too many elements (12288),
> in
> file lsystem.scad, line 69
>
> module path(points,width,closed=false) {
>    r=width/2;
>    for (i=[0:len(points)-2]) {
>       hull() {
>           translate(points[i]) circle(r);
>           translate(points[i+1]) circle(r);
>       }
>     }
>     if (closed) {
>       hull() {
>           translate(points[len(points)-1])
>               circle(r);
>           translate(points[0])
>               circle(r);
>       }
>     }
> };
>
> A workaround is to replace the range with a vector in the for statement:
>
> for (i=to_n(len(points)-2))
>
> where
>
> function to_n(n) = [for (i=0;i<=n;i=i+1) i];
>
> but this seems clumsy
> Any other ways to get past this limit - I believe it's 9999 ?
>
> Kit
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191015/083ff11d/attachment.html>


More information about the Discuss mailing list