[OpenSCAD] children not being passed to submodules

a.human a.human at tutanota.com
Sat Oct 15 17:10:18 EDT 2016


This works:
// Cut along y axis
module cut_shape_y(keep = "left"){
    if(keep == "left"){ 
        intersection(){ children(); left_xy_plane(); }
    }else if(keep == "right"){ 
        intersection(){ children(); right_xy_plane(); }
    }else if (keep == "both"){ 
        intersection(){ children(); left_xy_plane(); }
        intersection(){ children(); right_xy_plane(); }
    }
}

xy_plane modules are simply large squares that define the planes to enable
various cutting operations and such.

However, the following does not work, and issues no warnings or errors. It
simply draws the plane, the intersection never occurs because (I think) the
submodule doesn't receive the children of the main module.

// Cut along y axis
module cut_shape_y(keep = "left"){
    module left(){
        intersection(){
            children();
            left_xy_plane();
        }
    }
    module right(){
        intersection(){
            children();
            right_xy_plane();
        }
    }
    if(keep == "left"){ left();}
    else if(keep == "right"){ right();}
    else if (keep == "both"){ left(); right();}
}

Even calling left() children(); doesn't work instead of just left(); as in
the code above.

This is a scoping issue. Either it should throw a warning specifying that
submodules cannot access module's children, or better yet, it should work.





--
View this message in context: http://forum.openscad.org/children-not-being-passed-to-submodules-tp18722.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list