discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

adding and subtracting

JB
Jon Bondy
Sun, Oct 25, 2026 1:21 PM

Sometimes I want to add a standard receptacle to one of my designs. 
Think of adding an RJ45 connector (ethernet).  Part of the design is the
internal cavity that holds the socket, but part of the design cuts out a
hole in a surface for the cable to enter into the socket.

Is there a good practice for designing and then using both the additive
and subtractive parts of such a receptacle?

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Sometimes I want to add a standard receptacle to one of my designs.  Think of adding an RJ45 connector (ethernet).  Part of the design is the internal cavity that holds the socket, but part of the design cuts out a hole in a surface for the cable to enter into the socket. Is there a good practice for designing and then using both the additive and subtractive parts of such a receptacle? Jon -- This email has been checked for viruses by AVG antivirus software. www.avg.com
HW
Harvey white
Sun, Oct 25, 2026 3:53 PM

I have cutouts in cases for connectors.

I model the connector as a part, anything internal to the connector is
part of the connector.

I then (and I use red for preview) model a cutout for the connector,
it's a part of the connector itself, but its presence (as well as the
connector itself) is controlled by a global variable (something clever
like 'show_cutouts').  You can do a 'show_part' depending on what you
want, your choice of course.

the cutout automatically moves with the part.

so:  once the parts are automatically placed on the board model, you get...

  1. the board itself

  2. the board in the case, case includes the board model's cutouts.

  3. the case itself, minus the board and with the holes.

This works well for me.

Harvey

On 10/25/26 9:21 AM, Jon Bondy via Discuss wrote:

Sometimes I want to add a standard receptacle to one of my designs. 
Think of adding an RJ45 connector (ethernet).  Part of the design is
the internal cavity that holds the socket, but part of the design cuts
out a hole in a surface for the cable to enter into the socket.

Is there a good practice for designing and then using both the
additive and subtractive parts of such a receptacle?

Jon

I have cutouts in cases for connectors. I model the connector as a part, anything internal to the connector is part of the connector. I then (and I use red for preview) model a cutout for the connector, it's a part of the connector itself, but its presence (as well as the connector itself) is controlled by a global variable (something clever like 'show_cutouts').  You can do a 'show_part' depending on what you want, your choice of course. the cutout automatically moves with the part. so:  once the parts are automatically placed on the board model, you get... 1) the board itself 2) the board in the case, case includes the board model's cutouts. 3) the case itself, minus the board and with the holes. This works well for me. Harvey On 10/25/26 9:21 AM, Jon Bondy via Discuss wrote: > Sometimes I want to add a standard receptacle to one of my designs.  > Think of adding an RJ45 connector (ethernet).  Part of the design is > the internal cavity that holds the socket, but part of the design cuts > out a hole in a surface for the cable to enter into the socket. > > Is there a good practice for designing and then using both the > additive and subtractive parts of such a receptacle? > > Jon > >
JB
Jon Bondy
Sun, Oct 25, 2026 4:18 PM

Harvey:

Thanks!

A simple example might help me understand your approach better.

Jon

On 10/25/2026 11:53 AM, Harvey white via Discuss wrote:

I have cutouts in cases for connectors.

I model the connector as a part, anything internal to the connector is
part of the connector.

I then (and I use red for preview) model a cutout for the connector,
it's a part of the connector itself, but its presence (as well as the
connector itself) is controlled by a global variable (something clever
like 'show_cutouts').  You can do a 'show_part' depending on what you
want, your choice of course.

the cutout automatically moves with the part.

so:  once the parts are automatically placed on the board model, you
get...

  1. the board itself

  2. the board in the case, case includes the board model's cutouts.

  3. the case itself, minus the board and with the holes.

This works well for me.

Harvey

On 10/25/26 9:21 AM, Jon Bondy via Discuss wrote:

Sometimes I want to add a standard receptacle to one of my designs. 
Think of adding an RJ45 connector (ethernet).  Part of the design is
the internal cavity that holds the socket, but part of the design
cuts out a hole in a surface for the cable to enter into the socket.

Is there a good practice for designing and then using both the
additive and subtractive parts of such a receptacle?

Jon


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Harvey: Thanks! A simple example might help me understand your approach better. Jon On 10/25/2026 11:53 AM, Harvey white via Discuss wrote: > I have cutouts in cases for connectors. > > I model the connector as a part, anything internal to the connector is > part of the connector. > > I then (and I use red for preview) model a cutout for the connector, > it's a part of the connector itself, but its presence (as well as the > connector itself) is controlled by a global variable (something clever > like 'show_cutouts').  You can do a 'show_part' depending on what you > want, your choice of course. > > the cutout automatically moves with the part. > > so:  once the parts are automatically placed on the board model, you > get... > > 1) the board itself > > 2) the board in the case, case includes the board model's cutouts. > > 3) the case itself, minus the board and with the holes. > > This works well for me. > > Harvey > > > > On 10/25/26 9:21 AM, Jon Bondy via Discuss wrote: >> Sometimes I want to add a standard receptacle to one of my designs.  >> Think of adding an RJ45 connector (ethernet).  Part of the design is >> the internal cavity that holds the socket, but part of the design >> cuts out a hole in a surface for the cable to enter into the socket. >> >> Is there a good practice for designing and then using both the >> additive and subtractive parts of such a receptacle? >> >> Jon >> >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG antivirus software. www.avg.com
GB
Glenn Butcher
Sun, Oct 25, 2026 4:19 PM

I do this to make a cube corresponding to the window size for a
parameterized window model.  Key thing is to use the window width and
height to make the corresponding 'void cube', so one can change the
window size and the void cube follows along.  I've got selected models
that do this Thingiverse-style at a website on my personal server;
here's the page for my double-hung window model:

https://glenn.pulpitrock.net/customizable_models/doublehung_window/

Look for the parameter named window_opening_cutout.

The OpenSCAD code behind the website can be found, and downloaded, here:

https://github.com/butcherg/modelingtools

Glenn

On 10/25/2026 7:21 AM, Jon Bondy via Discuss wrote:

Sometimes I want to add a standard receptacle to one of my designs. 
Think of adding an RJ45 connector (ethernet).  Part of the design is
the internal cavity that holds the socket, but part of the design cuts
out a hole in a surface for the cable to enter into the socket.

Is there a good practice for designing and then using both the
additive and subtractive parts of such a receptacle?

Jon

I do this to make a cube corresponding to the window size for a parameterized window model.  Key thing is to use the window width and height to make the corresponding 'void cube', so one can change the window size and the void cube follows along.  I've got selected models that do this Thingiverse-style at a website on my personal server; here's the page for my double-hung window model: https://glenn.pulpitrock.net/customizable_models/doublehung_window/ Look for the parameter named window_opening_cutout. The OpenSCAD code behind the website can be found, and downloaded, here: https://github.com/butcherg/modelingtools Glenn On 10/25/2026 7:21 AM, Jon Bondy via Discuss wrote: > Sometimes I want to add a standard receptacle to one of my designs.  > Think of adding an RJ45 connector (ethernet).  Part of the design is > the internal cavity that holds the socket, but part of the design cuts > out a hole in a surface for the cable to enter into the socket. > > Is there a good practice for designing and then using both the > additive and subtractive parts of such a receptacle? > > Jon > >
AM
Adrian Mariano
Sun, Oct 25, 2026 7:04 PM

In BOSL2 you can create an attachable object that makes a subtraction from
its parent when diff() is invoked above the parent.  I think Example 22 for
attachable() shows how to do this.

On Sun, Oct 25, 2026 at 9:21 AM Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:

Sometimes I want to add a standard receptacle to one of my designs.
Think of adding an RJ45 connector (ethernet).  Part of the design is the
internal cavity that holds the socket, but part of the design cuts out a
hole in a surface for the cable to enter into the socket.

Is there a good practice for designing and then using both the additive
and subtractive parts of such a receptacle?

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

In BOSL2 you can create an attachable object that makes a subtraction from its parent when diff() is invoked above the parent. I think Example 22 for attachable() shows how to do this. On Sun, Oct 25, 2026 at 9:21 AM Jon Bondy via Discuss < discuss@lists.openscad.org> wrote: > Sometimes I want to add a standard receptacle to one of my designs. > Think of adding an RJ45 connector (ethernet). Part of the design is the > internal cavity that holds the socket, but part of the design cuts out a > hole in a surface for the cable to enter into the socket. > > Is there a good practice for designing and then using both the additive > and subtractive parts of such a receptacle? > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Mon, Oct 26, 2026 12:58 AM

Adrian's BOSL2 diff() answer is a good one.

Since I'm not really in the BOSL2 flow of things - I try sometimes, but
I often revert - what I usually do for this case is to put the part and
its negative
into one module, and have a flag that says whether the
module should generate the positive part or the negative part.

For instance, here's a part where the negative has a small gap around
the part to be inserted, that I've inserted into a larger cube.  (BOSL2
attachment makes this a lot easier.)

module mypart(neg = false) {
    gap = 0.5;
    dims = [20, 5, 3];
    if (neg) {
        cube(dims + 2*[gap, gap, gap], center=true);
    } else {
        cube(dims, center=true);
    }
}

difference() {
    cube(40);
    translate([40, 20, 20]) mypart(neg=true);
}
translate([40, 20, 20]) mypart();
Adrian's BOSL2 diff() answer is a good one. Since I'm not really in the BOSL2 flow of things - I try sometimes, but I often revert - what I usually do for this case is to put the part *and its negative* into one module, and have a flag that says whether the module should generate the positive part or the negative part. For instance, here's a part where the negative has a small gap around the part to be inserted, that I've inserted into a larger cube.  (BOSL2 attachment makes this a lot easier.) module mypart(neg = false) { gap = 0.5; dims = [20, 5, 3]; if (neg) { cube(dims + 2*[gap, gap, gap], center=true); } else { cube(dims, center=true); } } difference() { cube(40); translate([40, 20, 20]) mypart(neg=true); } translate([40, 20, 20]) mypart();
LM
Leonard Martin Struttmann
Mon, Oct 26, 2026 1:17 AM

I typically put all of the pieces of a part to be added and those to be
subtracted as separate modules within the part's own file.

For instance, if I am going to use an ESP32 MCU in my project, I will have
a file ESP32.scad that would contain modules such as ESP32(),
ESP32_USB_cutout(), and ESP32_standoffs().

Then in my project case file, I will

use <ESP32.scad>

In the module that models the case, I add the ESP32 MCU

%ESP32(); // To ensure it fits

...and the standoffs

ESP32_standoffs();

and difference away the ESP32_USB_cutout();

On Sun, Oct 25, 2026 at 7:58 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

Adrian's BOSL2 diff() answer is a good one.

Since I'm not really in the BOSL2 flow of things - I try sometimes, but I
often revert - what I usually do for this case is to put the part and its
negative
into one module, and have a flag that says whether the module
should generate the positive part or the negative part.

For instance, here's a part where the negative has a small gap around the
part to be inserted, that I've inserted into a larger cube.  (BOSL2
attachment makes this a lot easier.)

module mypart(neg = false) {
gap = 0.5;
dims = [20, 5, 3];
if (neg) {
cube(dims + 2*[gap, gap, gap], center=true);
} else {
cube(dims, center=true);
}
}

difference() {
cube(40);
translate([40, 20, 20]) mypart(neg=true);
}
translate([40, 20, 20]) mypart();


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I typically put all of the pieces of a part to be added and those to be subtracted as separate modules within the part's own file. For instance, if I am going to use an ESP32 MCU in my project, I will have a file ESP32.scad that would contain modules such as ESP32(), ESP32_USB_cutout(), and ESP32_standoffs(). Then in my project case file, I will use <ESP32.scad> In the module that models the case, I add the ESP32 MCU %ESP32(); // To ensure it fits ...and the standoffs ESP32_standoffs(); and difference away the ESP32_USB_cutout(); On Sun, Oct 25, 2026 at 7:58 PM Jordan Brown via Discuss < discuss@lists.openscad.org> wrote: > Adrian's BOSL2 diff() answer is a good one. > > Since I'm not really in the BOSL2 flow of things - I try sometimes, but I > often revert - what I usually do for this case is to put the part *and its > negative* into one module, and have a flag that says whether the module > should generate the positive part or the negative part. > > For instance, here's a part where the negative has a small gap around the > part to be inserted, that I've inserted into a larger cube. (BOSL2 > attachment makes this a lot easier.) > > module mypart(neg = false) { > gap = 0.5; > dims = [20, 5, 3]; > if (neg) { > cube(dims + 2*[gap, gap, gap], center=true); > } else { > cube(dims, center=true); > } > } > > difference() { > cube(40); > translate([40, 20, 20]) mypart(neg=true); > } > translate([40, 20, 20]) mypart(); > > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
HW
Harvey white
Mon, Oct 26, 2026 4:58 AM

Sorry if this is a re-post, oddities in the computer.

This should be a reasonable example:

// included punch example

// view = 0;           // LED
//  view = 1;           // case wall
// view = 2;           // case and LED
   view = 3;           // case and LED ghosted

module LED (c)
{
    $fn = 40;
    color(c) cylinder (d = 5, h = 15);
}

module LED_punch()
{
    $fn = 40;
   color(c) cylinder (d = 5.2, h = 20);
}
module wall (c)
{
    color(c) translate([0,0,13]) cube ([20,20,2],true);
}

if (view == 0)
{
    LED("green");
}

if (view == 1)
{
    difference()
    {
        wall("gray");
        LED_punch("red");
    }
}

if (view == 2)
{
    difference()
    {
        wall("gray");
        LED_punch("red");
    }
    LED("green");
}

if (view == 3)
{
    difference()
    {
        wall("gray");
        LED_punch("red");
    }
    LED("green");
    #LED_punch("red");
}

...............................................................................

The idea is that you must move the punch and the LED (in this example)
with the same coordinates, of course.

Harvey

On 10/25/26 12:18 PM, Jon Bondy via Discuss wrote:

Harvey:

Thanks!

A simple example might help me understand your approach better.

Jon

On 10/25/2026 11:53 AM, Harvey white via Discuss wrote:

I have cutouts in cases for connectors.

I model the connector as a part, anything internal to the connector
is part of the connector.

I then (and I use red for preview) model a cutout for the connector,
it's a part of the connector itself, but its presence (as well as the
connector itself) is controlled by a global variable (something
clever like 'show_cutouts').  You can do a 'show_part' depending on
what you want, your choice of course.

the cutout automatically moves with the part.

so:  once the parts are automatically placed on the board model, you
get...

  1. the board itself

  2. the board in the case, case includes the board model's cutouts.

  3. the case itself, minus the board and with the holes.

This works well for me.

Harvey

On 10/25/26 9:21 AM, Jon Bondy via Discuss wrote:

Sometimes I want to add a standard receptacle to one of my designs. 
Think of adding an RJ45 connector (ethernet).  Part of the design is
the internal cavity that holds the socket, but part of the design
cuts out a hole in a surface for the cable to enter into the socket.

Is there a good practice for designing and then using both the
additive and subtractive parts of such a receptacle?

Jon


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Sorry if this is a re-post, oddities in the computer. This should be a reasonable example: // included punch example // view = 0;           // LED //  view = 1;           // case wall // view = 2;           // case and LED    view = 3;           // case and LED ghosted module LED (c) {     $fn = 40;     color(c) cylinder (d = 5, h = 15); } module LED_punch() {     $fn = 40;    color(c) cylinder (d = 5.2, h = 20); } module wall (c) {     color(c) translate([0,0,13]) cube ([20,20,2],true); } if (view == 0) {     LED("green"); } if (view == 1) {     difference()     {         wall("gray");         LED_punch("red");     } } if (view == 2) {     difference()     {         wall("gray");         LED_punch("red");     }     LED("green"); } if (view == 3) {     difference()     {         wall("gray");         LED_punch("red");     }     LED("green");     #LED_punch("red"); } ............................................................................... The idea is that you must move the punch and the LED (in this example) with the same coordinates, of course. Harvey On 10/25/26 12:18 PM, Jon Bondy via Discuss wrote: > Harvey: > > Thanks! > > A simple example might help me understand your approach better. > > Jon > > On 10/25/2026 11:53 AM, Harvey white via Discuss wrote: >> I have cutouts in cases for connectors. >> >> I model the connector as a part, anything internal to the connector >> is part of the connector. >> >> I then (and I use red for preview) model a cutout for the connector, >> it's a part of the connector itself, but its presence (as well as the >> connector itself) is controlled by a global variable (something >> clever like 'show_cutouts').  You can do a 'show_part' depending on >> what you want, your choice of course. >> >> the cutout automatically moves with the part. >> >> so:  once the parts are automatically placed on the board model, you >> get... >> >> 1) the board itself >> >> 2) the board in the case, case includes the board model's cutouts. >> >> 3) the case itself, minus the board and with the holes. >> >> This works well for me. >> >> Harvey >> >> >> >> On 10/25/26 9:21 AM, Jon Bondy via Discuss wrote: >>> Sometimes I want to add a standard receptacle to one of my designs.  >>> Think of adding an RJ45 connector (ethernet).  Part of the design is >>> the internal cavity that holds the socket, but part of the design >>> cuts out a hole in a surface for the cable to enter into the socket. >>> >>> Is there a good practice for designing and then using both the >>> additive and subtractive parts of such a receptacle? >>> >>> Jon >>> >>> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jon Bondy
Mon, Oct 26, 2026 8:27 PM

Thank you

As is often the case with some parts of BOSL2, it is beyond me.

Jon

On 10/25/2026 3:04 PM, Adrian Mariano via Discuss wrote:

In BOSL2 you can create an attachable object that makes a subtraction
from its parent when diff() is invoked above the parent.  I think
Example 22 for attachable() shows how to do this.

On Sun, Oct 25, 2026 at 9:21 AM Jon Bondy via Discuss
discuss@lists.openscad.org wrote:

 Sometimes I want to add a standard receptacle to one of my designs.
 Think of adding an RJ45 connector (ethernet).  Part of the design
 is the
 internal cavity that holds the socket, but part of the design cuts
 out a
 hole in a surface for the cable to enter into the socket.

 Is there a good practice for designing and then using both the
 additive
 and subtractive parts of such a receptacle?

 Jon


 -- 
 This email has been checked for viruses by AVG antivirus software.
 www.avg.com
 <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=gD5QSgqc4QN4gNMGBtr8oYPrPe0AWs_zy4ToUE-nIIWQ2qR1q_P4KKh0b7udVPPs&s=yFNnwUr60RMzEEz7PCPSZjMErt2DMQJFyMCcywUhR2Y&e=>
 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org

OpenSCAD mailing list
To unsubscribe send an email todiscuss-leave@lists.openscad.org

Thank you As is often the case with some parts of BOSL2, it is beyond me. Jon On 10/25/2026 3:04 PM, Adrian Mariano via Discuss wrote: > In BOSL2 you can create an attachable object that makes a subtraction > from its parent when diff() is invoked above the parent.  I think > Example 22 for attachable() shows how to do this. > > > > > > On Sun, Oct 25, 2026 at 9:21 AM Jon Bondy via Discuss > <discuss@lists.openscad.org> wrote: > > Sometimes I want to add a standard receptacle to one of my designs. > Think of adding an RJ45 connector (ethernet).  Part of the design > is the > internal cavity that holds the socket, but part of the design cuts > out a > hole in a surface for the cable to enter into the socket. > > Is there a good practice for designing and then using both the > additive > and subtractive parts of such a receptacle? > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=gD5QSgqc4QN4gNMGBtr8oYPrPe0AWs_zy4ToUE-nIIWQ2qR1q_P4KKh0b7udVPPs&s=yFNnwUr60RMzEEz7PCPSZjMErt2DMQJFyMCcywUhR2Y&e=> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org