[OpenSCAD] adding a difference causes 2-manifold error?

Michael Frey michael.frey at gmx.ch
Sat Oct 27 13:30:32 EDT 2018


Hi John,

/(Note: I send some more screenshoots to John directly - those are too 
big for the mailing list.)/

Let us start bit the difference with the two "bits".

When I add the # modifier, I see Z-Fighting.

Z-Fighting occurs when faces are coincident - OpenSCAD does not like 
that as it is not clear whether the surface belongs to the model or not.

Please move the second bit down and make it a longer:

---------


adding the # modifier to if (cover > 0) {

that looks unclean:

so, let us move this cube up a bit:

and also the other cube, but the other cube has to be translated down a bit.

---------

adding the modifier # to if (spx<0) {

again, Z-Fighting:

so, move it down a bit:


With kind regards,

Michael Frey

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20181027/c35d04b1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: djgmbgjkhpolibfh.png
Type: image/png
Size: 26279 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20181027/c35d04b1/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hjjgnaipmhiflhnp.png
Type: image/png
Size: 1150 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20181027/c35d04b1/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mnkebgeolojobhmn.png
Type: image/png
Size: 15638 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20181027/c35d04b1/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ajdpinfalbmloklk.png
Type: image/png
Size: 4937 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20181027/c35d04b1/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: maaholgpmnpdiepg.png
Type: image/png
Size: 26407 bytes
Desc: not available
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20181027/c35d04b1/attachment-0004.png>
-------------- next part --------------
// Cover=1, holder=0 - creates just the base cover plate
// Cover=1, holder=1 - creates the bit holder shaped to work with the cover
// Cover=0, holder=1 - creates just the bit holder, does NOT work with the cover plate

// Non-Zero to create the base cover
cover=1;
// Non-Zero to create the bit holder
holder=1;

//Number of bits in x-direction [>0]
nx=3;
//Number of bits in y-direction [>0]
ny=2;
//Spacing in x-direction [mm]. Values below 0 will connect the hexagonal shapes.
spx=-.5;
//Spacing in y-direction [mm]. Values below 0 will connect.
spy=4;
//Depth of the hexagon shape for the bit [>1mm]. I advise >=6mm.
bhh=7;
//Thickness of the connecting bottom layer [>1mm]
bh=3;
//Skirt into the negative x-axis (west) [>0mm] (for fixing, holding down or labelling)
xb1=6;
//Skirt into the positive x-axis (east) [>0mm]
xb2=6;
//Skirt into the negative y-axis (south) [>0mm]
yb1=1;
//Skirt into the positive y-axis (north) [>0mm]
yb2=1;
//Thickness of the walls for the bitholders [0.3-3mm]. Also consider your nozzle-/print-width.
wt=2.5;
//Tightness. [0-100%], 0 is very loose, 100% is very tight!
tn=45;
//Circular magnet hole depth [0-(bh) mm]. Read more in this Things description. If you don't want to add magnets, set to zero.
mht=3;
//Magnet hole diameter [0-8mm]. Don't forget to add a little print tolerance!If you don't want to add magnets, set to zero.
mhd=8;
//Squeezers, set to 0 for No Squeezers, 1` otherwise.  you probably don't need this if you use magnets
sqz=0;

wallthickness=min(max(wt,0.3), 3);
ex=max(nx,1);
ey=max(ny,1);
bitholderdepth=max(bhh,1);
baseheight=max(bh,1);
yborder1=max(yb1,0);
yborder2=max(yb2,0);
xborder1=max(xb1,0);
xborder2=max(xb2,0);
innerbitradius=6.25+1.35;
sx = max(spx,-1)+innerbitradius+0.9+0.1;
sy = max(spy,-0.85)+innerbitradius+0.1;
tns=max(min(tn,100),0);
magt=max(min(mht, bh), 0);
magd=max(min(mhd, 8), 0);


difference() {
    union() {
        //Baseplate
        translate([-xborder1,-yborder1,0]) {
            minkowski() {
                cube([max((ex-1)*sx+xborder1+xborder2,0.01), max((ey-1)*sy+yborder1+yborder2,0.01), baseheight/2]);
                cylinder(d=7.6+wallthickness, h=baseheight/2, $fn=100);
            }
        }
        //Add the actual hexagonal bit holders
        //render()
       difference() {
            for (x = [0:1:ex-1]) {
                for (y = [0:1:ey-1]) {
                    translate([x*sx,y*sy, baseheight]) {
                        bit(h=bitholderdepth, r=innerbitradius+wallthickness);
                    }
                }
            }
            
            for (x = [0:1:ex-1]) {
                for (y = [0:1:ey-1]) {
                    translate([x*sx,y*sy, baseheight-0.5]) {
                        bit(h=bitholderdepth+1.0, r=innerbitradius);
                    }
                }
            }
        }
    }
    
    if (spx<0) {
        for (y = [0:1:ey-1]) {
            s=0;
            translate([0, -s/2+y*sy-wallthickness/2, baseheight-0.01]) {
                cube([(ex-1)*innerbitradius, s+wallthickness, bitholderdepth+0.5]);
            }
        }
    }
    
    //Holes for magnets
    if (magt != 0 && magd != 0) {
        for (x = [0:1:ex-1]) {
            for (y = [0:1:ey-1]) {
                if (magt==bh) {
                    translate([x*sx,y*sy, magt/2]) {
                        cylinder(d=magd, h=magt+0.2, center=true, $fn=100);
                    }
                } else {
                    translate([x*sx,y*sy, magt/2-0.05]) {
                        cylinder(d=magd, h=magt+0.1, center=true, $fn=100);
                    }
                }
            }
        }
    }
    
    if (cover > 0) {
        translate([-xborder1-7.6+wallthickness,
                   -yborder1-7.6+wallthickness-baseheight,
                   0.02]) {
            rotate([-15,0,0]) {
                cube([max((ex-1)*sx+xborder1+xborder2,0.01)+7.6+wallthickness, 
                      baseheight, 
                      baseheight*1.3], false);
            }
        }
        #translate([-xborder1-7.6+wallthickness,
                   +yborder1+max((ey-1)*sy+yborder1+yborder2,0.01)+baseheight,
                   -0.02]) {
            rotate([15,0,0]) {
                cube([max((ex-1)*sx+xborder1+xborder2,0.01)+7.6+wallthickness, 
                      baseheight, 
                      baseheight*1.3], false);
            }
        }
    }
}


module bit(r,h) {
    translate([0,0,h/2]) {
        cylinder(d=r, $fn=6, h=h, center=true);
    }
}



More information about the Discuss mailing list