[OpenSCAD] When modules are cached?

Ronaldo Persiano rcmpersiano at gmail.com
Tue Oct 29 12:50:12 EDT 2019

As illustration of my concerns, please look at the following code:

A(50000) C();

module C() square(10,center=true);

module B() {
        projection() rotate([10,20,30]) cube(1000,center=true);
        projection() rotate([20,30,10]) cube(1000,center=true);
        projection() rotate([30,10,20]) cube(1000,center=true);

module A(n=0)
  for(i=[for(i=0;i<n;i=i+1) i]) rotate(360*i/n) children();

B() is a very expensive way to construct the same geometry (a square) of
C(). None of them have parameters. A() is just a multiple rotation of its

As is, this code runs in 4 sec in my machine. If I exchange the places of
B() and C() in the main code and flush the cache, the code runs in 23 sec.
I would expect that both B() and C() were evaluated once and their cached
geometry were used in both versions of the main code. If was that so, both
main code would have the same runtime.

What objects are cached? When they are cached?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20191029/150776c2/attachment.html>

More information about the Discuss mailing list