garyhodgson / openscad.net

OpenSCAD.net is a partial port of OpenSCAD for the web. Powered by OpenJsCad, it uses the familiar OpenSCAD syntax to allow many OpenSCAD models to be rendered, and saved as STL, via the browser.
https://garyhodgson.github.io/openscad.net/
50 stars 8 forks source link

Nested for loop CSG op produces different output to OpenSCAD #3

Closed garyhodgson closed 11 years ago

garyhodgson commented 11 years ago
module m1(i)
{
    translate([i,0,0])
    cube(8, center = true);
}

for (i = [ 3:5 ]) {
    difference(){
        m1(i);
        sphere(r = 5);
    }
}

Produces a shorter block than in OpenSCAD

garyhodgson commented 11 years ago

function appears to be called 3 times (an echo statement in it is called three times, but i is shown to be always 3), and the resulting jscad is:

function main(){

return CSG.cube({center: [0,0,0],radius: [4,4,4], resolution: 16}).translate([3,0,0]).subtract([CSG.sphere({center: [0,0,0], radius: 5, resolution: 16})]);
};