SolidCode / SolidPython

A python frontend for solid modelling that compiles to OpenSCAD
1.12k stars 175 forks source link

hole turns differences into unions #82

Open davidji opened 7 years ago

davidji commented 7 years ago

E.g.

I expect

from solid import *
from solid.utils import *

def hole_difference():
    return cube([20,20,20], center=True) + hole()(cube([10,10,20], center=True) - cylinder(d=10, h = 20))

if __name__ == '__main__':
    scad_render_to_file(hole_difference(), 'hole_union.scad')

to produce

difference(){
    union() {
        cube(center = true, size = [20, 20, 20]);
    }
    /* Holes Below*/
    union(){
        difference() {
            cube(center = true, size = [10, 10, 20]);
            cylinder(d = 10, h = 20);
        }
    } /* End Holes */ 
}

but it produces

difference(){
    union() {
        cube(center = true, size = [20, 20, 20]);
    }
    /* Holes Below*/
    union(){
        union() {
            cube(center = true, size = [10, 10, 20]);
            cylinder(d = 10, h = 20);
        }
    } /* End Holes */ 
}