Hello everyone,
I am hoping to be able to design parametric drawer inserts for lasercutting.
Here is a simple example of a two-part lasercuttable 3D form:
eps = 0.01;
// create and cut the base properly
difference() {
// base piece to be cut into
color("yellow")
translate ([eps,0,-6]) cube([20,20,6]);
// vertical piece with tab
color("green")
union(){
cube([6,20,30]);
translate ([0,5,-6-eps]) cube([6,10,6+eps]);
}
}
/* this part was discarded after the difference operation,
so need to recreate it */
// vertical piece with tab
color("red")
union(){
cube([6,20,30]);
translate ([0,5,-6-eps]) cube([6,10,6+eps]);
}
I have a two questions:
Can I export two distinct DXFs from this file, one of an XY face of the yellow body, and one of a XZ face of the red body? (I’d need to do this to be able to lasercut.)
Is there a way to tell OpenSCAD not to discard the subtrahend of the difference operation? In CAD software, this would be an option called something like “keep cutting tool.” I’m aware of the # symbol in front of a command for displaying the ghost of the body; that’s not what I’m looking for.
Thanks!
Am Do., 19. Aug. 2021 um 18:02 Uhr schrieb bobby.zacharias@gmail.com:
Hello everyone,
I am hoping to be able to design parametric drawer inserts for
lasercutting.
Here is a simple example of a two-part lasercuttable 3D form:
eps = 0.01;
// create and cut the base properly
difference() {
// base piece to be cut into
color("yellow")
translate ([eps,0,-6]) cube([20,20,6]);
// vertical piece with tab
color("green")
union(){
cube([6,20,30]);
translate ([0,5,-6-eps]) cube([6,10,6+eps]);
}
}
/* this part was discarded after the difference operation,
so need to recreate it */
// vertical piece with tab
color("red")
union(){
cube([6,20,30]);
translate ([0,5,-6-eps]) cube([6,10,6+eps]);
}
I have a two questions:
Can I export two distinct DXFs from this file, one of an XY face of the
yellow body, and one of a XZ face of the red body? (I’d need to do this to
be able to lasercut.)
Is there a way to tell OpenSCAD not to discard the subtrahend of the
difference operation? In CAD software, this would be an option called
something like “keep cutting tool.” I’m aware of the # symbol in front of a
command for displaying the ghost of the body; that’s not what I’m looking
for.
Thanks!
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
On 8/19/2021 9:02 AM, bobby.zacharias@gmail.com wrote:
One run can yield only one output. However, you could have a flag that
you could set to say which of the two outputs you want to produce. You
could set the flag manually by editing the program, or you could rig it
for the customizer, or you could rig it so that you do the final renders
from the CLI with a script.
I have some tooling - a couple of OpenSCAD modules and a shell script -
that let me have a single OpenSCAD file that generates several parts, to
be rendered one at a time or in combinations. In my particular case, I
want to generate PNGs of parts or combinations of parts, and STLs of
individual parts (for printing) or combinations of parts (for
visualization). I run the script and it runs the OpenSCAD program once
to collect an inventory of what is to be done, then runs OpenSCAD once
for each file to be created. I'm happy to share that if you're interested.
What does this really mean? If you "keep" the subtrahend, what would
happen to it? If you keep it straightforwardly, it'd just be unioned
back into the difference, for a net result of zero change.
In your example, the first thing I would think of would be to wrap that
subtrahend in a module, so you don't have to duplicate it.
It looks like you want the subtrahend to be a different color. Here's a
module that would do something like that.
module colordiff(colors) {
assert(len(colors) == $children);
color(colors[0]) difference() {
children(0);
for (i=[1:$children-1]) children(i);
}
for (i = [1:$children-1]) color(colors[i]) children(i);
}
colordiff(["red", "white", "blue"]) {
cube(10);
translate([5,5,5]) cube(10);
translate([-5,-5,-5]) cube(10);
}
But: because of OpenSCAD's somewhat limited color mechanisms, I'm not
sure that's different from just creating the three cubes as overlapping
objects. Also I suspect that there will be Z-fighting if they share faces.