discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

union bug or simply blind?

SH
stefan harjes
Sun, Aug 2, 2015 6:14 AM

Hi openSCAD,
for some reason when I remove the highlight '#' in the below macro, the two corresponding cubes simply vanish, instead of being added to the enclosing union. While my design works when I split the difference(), it would be nice to have it in one place, or maybe it is only my system?

$fn=25;
wall=3;
spacer=0.02;
neuH=93;
neuB=121;
oldH=86;
oldB=150;
shiftX=(oldB-neuB)/2;

difference(){
  union(){
    translate([-shiftX+wall,0,0]) { cube([oldB,oldH,wall]); };
    cube([neuB+2wall,neuH+wall,6wall]);
  #  translate([wall+neuB-30,0,0]) { cube([30,20,wall]); };
  #  translate([wall,neuH-17,0]) { cube([34,17,wall]); }; 
  };
  union(){
    translate([wall,-spacer,wall+spacer]) {cube([neuB,neuH+spacer,5wall+spacer]);};
    translate([2
wall,4wall-spacer,-wall]) {cube([neuB-2wall,neuH-5wall+spacer,7wall]);};
    translate([0,0,0]) { cube([0,0,0]); };
    translate([-shiftX+oldB-6+wall,oldH-5,-20]) { cylinder(50,1.5,1.5); };
    translate([-shiftX+oldB-5.5+wall,16.2,-20]) { cylinder(50,1.5,1.5); };
    translate([-shiftX+29.8+wall,+5.7,-20]) { cylinder(50,1.5,1.5); };
    translate([-shiftX+6+wall,oldH-5,-20]) { cylinder(50,1.5,1.5); };
    translate([neuB-22.7+wall,12.6,-20]) { cylinder(50,2.35,2.35); };   
    translate([wall+26.5,neuH-9.5,-20]) { cylinder(50,2.35,2.35); };   
    translate([wall+neuB-30-70,2wall,-spacer]) {cube([70,7,wall2]); };
    translate([neuB-20,39,wall+6.2]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; };
    translate([-20,21.5,wall+10]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; };
    translate([-20,neuH-21.5,wall+10]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; };
  };
};

Hi openSCAD, for some reason when I remove the highlight '#' in the below macro, the two corresponding cubes simply vanish, instead of being added to the enclosing union. While my design works when I split the difference(), it would be nice to have it in one place, or maybe it is only my system? $fn=25; wall=3; spacer=0.02; neuH=93; neuB=121; oldH=86; oldB=150; shiftX=(oldB-neuB)/2; difference(){   union(){     translate([-shiftX+wall,0,0]) { cube([oldB,oldH,wall]); };     cube([neuB+2*wall,neuH+wall,6*wall]);   #  translate([wall+neuB-30,0,0]) { cube([30,20,wall]); };   #  translate([wall,neuH-17,0]) { cube([34,17,wall]); };    };   union(){     translate([wall,-spacer,wall+spacer]) {cube([neuB,neuH+spacer,5*wall+spacer]);};     translate([2*wall,4*wall-spacer,-wall]) {cube([neuB-2*wall,neuH-5*wall+spacer,7*wall]);};     translate([0,0,0]) { cube([0,0,0]); };     translate([-shiftX+oldB-6+wall,oldH-5,-20]) { cylinder(50,1.5,1.5); };     translate([-shiftX+oldB-5.5+wall,16.2,-20]) { cylinder(50,1.5,1.5); };     translate([-shiftX+29.8+wall,+5.7,-20]) { cylinder(50,1.5,1.5); };     translate([-shiftX+6+wall,oldH-5,-20]) { cylinder(50,1.5,1.5); };     translate([neuB-22.7+wall,12.6,-20]) { cylinder(50,2.35,2.35); };        translate([wall+26.5,neuH-9.5,-20]) { cylinder(50,2.35,2.35); };        translate([wall+neuB-30-70,2*wall,-spacer]) {cube([70,7,wall*2]); };     translate([neuB-20,39,wall+6.2]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; };     translate([-20,21.5,wall+10]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; };     translate([-20,neuH-21.5,wall+10]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; };   }; };
M
MichaelAtOz
Sun, Aug 2, 2015 6:35 AM

Hadd me stumped for a minute...

The # makes it display that bit, even tho it is removed by the difference,
it is for debugging.

Try

$fn=25;
wall=3;
spacer=0.02;
neuH=93;
neuB=121;
oldH=86;
oldB=150;
shiftX=(oldB-neuB)/2;

difference(){
color("black",0.3) union(){
translate([-shiftX+wall,0,0]) cube([oldB,oldH,wall]); ;
cube([neuB+2wall,neuH+wall,6wall]);

};
color("blue",0.3) union(){
translate([wall,-spacer,wall+spacer])
{cube([neuB,neuH+spacer,5wall+spacer]);};
translate([2
wall,4wall-spacer,-wall])
{cube([neuB-2
wall,neuH-5wall+spacer,7wall]);};
// translate([0,0,0]) { cube([0,0,0]); };
translate([-shiftX+oldB-6+wall,oldH-5,-20]) { cylinder(50,1.5,1.5); };
translate([-shiftX+oldB-5.5+wall,16.2,-20]) { cylinder(50,1.5,1.5); };
translate([-shiftX+29.8+wall,+5.7,-20]) { cylinder(50,1.5,1.5); };
translate([-shiftX+6+wall,oldH-5,-20]) { cylinder(50,1.5,1.5); };
translate([neuB-22.7+wall,12.6,-20]) { cylinder(50,2.35,2.35); };
translate([wall+26.5,neuH-9.5,-20]) { cylinder(50,2.35,2.35); };
translate([wall+neuB-30-70,2wall,-spacer]) {cube([70,7,wall2]); };
translate([neuB-20,39,wall+6.2]) { rotate([0,90,0]) {
cylinder(50,1.5,1.5); }; };
translate([-20,21.5,wall+10]) { rotate([0,90,0]) { cylinder(50,1.5,1.5);
}; };
translate([-20,neuH-21.5,wall+10]) { rotate([0,90,0]) {
cylinder(50,1.5,1.5); }; };
};
};

translate([wall+neuB-30,0,0]) cube([30,20,wall]); ;
translate([wall,neuH-17,0])  cube([34,17,wall]); ;

That way you add the two extra bits AFTER the cutouts are done.


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

View this message in context: http://forum.openscad.org/union-bug-or-simply-blind-tp13396p13397.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hadd me stumped for a minute... The # makes it display that bit, even tho it is removed by the difference, it is for debugging. Try $fn=25; wall=3; spacer=0.02; neuH=93; neuB=121; oldH=86; oldB=150; shiftX=(oldB-neuB)/2; difference(){ color("black",0.3) union(){ translate([-shiftX+wall,0,0]) cube([oldB,oldH,wall]); ; cube([neuB+2*wall,neuH+wall,6*wall]); }; color("blue",0.3) union(){ translate([wall,-spacer,wall+spacer]) {cube([neuB,neuH+spacer,5*wall+spacer]);}; translate([2*wall,4*wall-spacer,-wall]) {cube([neuB-2*wall,neuH-5*wall+spacer,7*wall]);}; // translate([0,0,0]) { cube([0,0,0]); }; translate([-shiftX+oldB-6+wall,oldH-5,-20]) { cylinder(50,1.5,1.5); }; translate([-shiftX+oldB-5.5+wall,16.2,-20]) { cylinder(50,1.5,1.5); }; translate([-shiftX+29.8+wall,+5.7,-20]) { cylinder(50,1.5,1.5); }; translate([-shiftX+6+wall,oldH-5,-20]) { cylinder(50,1.5,1.5); }; translate([neuB-22.7+wall,12.6,-20]) { cylinder(50,2.35,2.35); }; translate([wall+26.5,neuH-9.5,-20]) { cylinder(50,2.35,2.35); }; translate([wall+neuB-30-70,2*wall,-spacer]) {cube([70,7,wall*2]); }; translate([neuB-20,39,wall+6.2]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; }; translate([-20,21.5,wall+10]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; }; translate([-20,neuH-21.5,wall+10]) { rotate([0,90,0]) { cylinder(50,1.5,1.5); }; }; }; }; translate([wall+neuB-30,0,0]) cube([30,20,wall]); ; translate([wall,neuH-17,0]) cube([34,17,wall]); ; That way you add the two extra bits AFTER the cutouts are done. ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/union-bug-or-simply-blind-tp13396p13397.html Sent from the OpenSCAD mailing list archive at Nabble.com.
A
Amedee
Sun, Aug 2, 2015 6:36 AM

Hi!

They don't magically disappear and they are added to the union() but you
subtract them afterwards with
translate([2wall,4wall-spacer,-wall])
{cube([neuB-2wall,neuH-5wall+spacer,7*wall]);};

So you need to either make a more complex subtract shape or add your cubes
outside the difference()...

--
View this message in context: http://forum.openscad.org/union-bug-or-simply-blind-tp13396p13398.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi! They don't magically disappear and they are added to the union() but you subtract them afterwards with translate([2*wall,4*wall-spacer,-wall]) {cube([neuB-2*wall,neuH-5*wall+spacer,7*wall]);}; So you need to either make a more complex subtract shape or add your cubes outside the difference()... -- View this message in context: http://forum.openscad.org/union-bug-or-simply-blind-tp13396p13398.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Sun, Aug 2, 2015 8:52 AM

Note: you don't need to union all the subtracted bits. Difference() takes
multiple children and subtracts them all from the first child.

On 2 August 2015 at 07:36, Amedee openscad@e.bulles.eu wrote:

Hi!

They don't magically disappear and they are added to the union() but you
subtract them afterwards with
translate([2wall,4wall-spacer,-wall])
{cube([neuB-2wall,neuH-5wall+spacer,7*wall]);};

So you need to either make a more complex subtract shape or add your cubes
outside the difference()...

--
View this message in context:
http://forum.openscad.org/union-bug-or-simply-blind-tp13396p13398.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Note: you don't need to union all the subtracted bits. Difference() takes multiple children and subtracts them all from the first child. On 2 August 2015 at 07:36, Amedee <openscad@e.bulles.eu> wrote: > Hi! > > They don't magically disappear and they are added to the union() but you > subtract them afterwards with > translate([2*wall,4*wall-spacer,-wall]) > {cube([neuB-2*wall,neuH-5*wall+spacer,7*wall]);}; > > So you need to either make a more complex subtract shape or add your cubes > outside the difference()... > > > > -- > View this message in context: > http://forum.openscad.org/union-bug-or-simply-blind-tp13396p13398.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >