discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

BOSL2 Newbie Question

LM
Leonard Martin Struttmann
Tue, Feb 6, 2024 1:13 AM

Hello, all!  In an attempt to teach myself about BOSL2 attachables, I am
trying to model a simple PC board.

I create the board and then drill some mounting holes.

Now, how do I add a component and attach it to the PCB?

Obviously, I'm missing some key concepts about how to use attachables.

The attached code illustrates what I have tried and does not work.

Any ideas?  Thanks!  Len

//
---========
include <BOSL2/std.scad>

MCUboardXYZ = [ 65.98, 2.025.4, 1.63];
MCUboardHoleOffsetsXY = [25.4
[2.505,2-.09994], 25.4*[2.51,2-1.89494]];
MCUboardHoleD = 0.125*25.4;
MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25];
MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0];

MCUboardBOSL2();

module MCUboardBOSL2()
{
diff("holes")
{
cube(MCUboardXYZ, center=false)

tag("holes")
for (i=MCUboardHoleOffsetsXY)
{
  move( [i.x, i.y, -0.001 ] )
  position(FRONT+LEFT+BOTTOM)
  cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false);
}

}

// left(0.34) back(MCUBoardPowerSUpplyOffsets.y)
//  position(BACK+LEFT+BOTTOM)
cube(MCUBoardPowerSupplyXYZ);

}

Hello, all! In an attempt to teach myself about BOSL2 attachables, I am trying to model a simple PC board. I create the board and then drill some mounting holes. Now, how do I add a component and attach it to the PCB? Obviously, I'm missing some key concepts about how to use attachables. The attached code illustrates what I have tried and does not work. Any ideas? Thanks! Len //========================================= include <BOSL2/std.scad> MCUboardXYZ = [ 65.98, 2.0*25.4, 1.63]; MCUboardHoleOffsetsXY = [25.4*[2.505,2-.09994], 25.4*[2.51,2-1.89494]]; MCUboardHoleD = 0.125*25.4; MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25]; MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0]; MCUboardBOSL2(); module MCUboardBOSL2() { diff("holes") { cube(MCUboardXYZ, center=false) tag("holes") for (i=MCUboardHoleOffsetsXY) { move( [i.x, i.y, -0.001 ] ) position(FRONT+LEFT+BOTTOM) cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false); } } // left(0.34) back(MCUBoardPowerSUpplyOffsets.y) // position(BACK+LEFT+BOTTOM) cube(MCUBoardPowerSupplyXYZ); }
AM
Adrian Mariano
Fri, Feb 9, 2024 9:51 PM

You aren't very clear about what you actually want to do in this question.
But one thing is obviously giving you trouble:  your cube at the bottom is
not a child of the main cube that defines the board.  Attachments work by
being children of other objects.  So for example:

include <BOSL2/std.scad>

MCUboardXYZ = [ 65.98, 2.025.4, 1.63];
MCUboardHoleOffsetsXY = [25.4
[2.505,2-.09994], 25.4*[2.51,2-1.89494]];
MCUboardHoleD = 0.125*25.4;
MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25];
MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0];

MCUboardBOSL2();

module MCUboardBOSL2()
{
diff("holes")
{
cube(MCUboardXYZ, center=false)
{
tag("holes")
for (i=MCUboardHoleOffsetsXY)
{
move( [i.x, i.y, -0.001 ] )
position(FRONT+LEFT+BOTTOM)
cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false);
}
align(BACK+TOP)
cube(MCUBoardPowerSupplyXYZ);
}
}
}

On Mon, Feb 5, 2024 at 8:14 PM Leonard Martin Struttmann via Discuss <
discuss@lists.openscad.org> wrote:

Hello, all!  In an attempt to teach myself about BOSL2 attachables, I am
trying to model a simple PC board.

I create the board and then drill some mounting holes.

Now, how do I add a component and attach it to the PCB?

Obviously, I'm missing some key concepts about how to use attachables.

The attached code illustrates what I have tried and does not work.

Any ideas?  Thanks!  Len

//
---========
include <BOSL2/std.scad>

MCUboardXYZ = [ 65.98, 2.025.4, 1.63];
MCUboardHoleOffsetsXY = [25.4
[2.505,2-.09994], 25.4*[2.51,2-1.89494]];
MCUboardHoleD = 0.125*25.4;
MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25];
MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0];

MCUboardBOSL2();

module MCUboardBOSL2()
{
diff("holes")
{
cube(MCUboardXYZ, center=false)

 tag("holes")
 for (i=MCUboardHoleOffsetsXY)
 {
   move( [i.x, i.y, -0.001 ] )
   position(FRONT+LEFT+BOTTOM)
   cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false);
 }

}

// left(0.34) back(MCUBoardPowerSUpplyOffsets.y)
//  position(BACK+LEFT+BOTTOM)
cube(MCUBoardPowerSupplyXYZ);

}


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

You aren't very clear about what you actually want to do in this question. But one thing is obviously giving you trouble: your cube at the bottom is not a child of the main cube that defines the board. Attachments work by being children of other objects. So for example: include <BOSL2/std.scad> MCUboardXYZ = [ 65.98, 2.0*25.4, 1.63]; MCUboardHoleOffsetsXY = [25.4*[2.505,2-.09994], 25.4*[2.51,2-1.89494]]; MCUboardHoleD = 0.125*25.4; MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25]; MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0]; MCUboardBOSL2(); module MCUboardBOSL2() { diff("holes") { cube(MCUboardXYZ, center=false) { tag("holes") for (i=MCUboardHoleOffsetsXY) { move( [i.x, i.y, -0.001 ] ) position(FRONT+LEFT+BOTTOM) cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false); } align(BACK+TOP) cube(MCUBoardPowerSupplyXYZ); } } } On Mon, Feb 5, 2024 at 8:14 PM Leonard Martin Struttmann via Discuss < discuss@lists.openscad.org> wrote: > Hello, all! In an attempt to teach myself about BOSL2 attachables, I am > trying to model a simple PC board. > > I create the board and then drill some mounting holes. > > Now, how do I add a component and attach it to the PCB? > > Obviously, I'm missing some key concepts about how to use attachables. > > The attached code illustrates what I have tried and does not work. > > Any ideas? Thanks! Len > > //========================================= > include <BOSL2/std.scad> > > MCUboardXYZ = [ 65.98, 2.0*25.4, 1.63]; > MCUboardHoleOffsetsXY = [25.4*[2.505,2-.09994], 25.4*[2.51,2-1.89494]]; > MCUboardHoleD = 0.125*25.4; > MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25]; > MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0]; > > MCUboardBOSL2(); > > module MCUboardBOSL2() > { > diff("holes") > { > cube(MCUboardXYZ, center=false) > > tag("holes") > for (i=MCUboardHoleOffsetsXY) > { > move( [i.x, i.y, -0.001 ] ) > position(FRONT+LEFT+BOTTOM) > cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false); > } > } > > // left(0.34) back(MCUBoardPowerSUpplyOffsets.y) > // position(BACK+LEFT+BOTTOM) > cube(MCUBoardPowerSupplyXYZ); > > } > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
LM
Leonard Martin Struttmann
Sat, Feb 10, 2024 1:47 AM

Thanks, Adrian!  That was exactly the tip that I needed.

On Fri, Feb 9, 2024 at 4:16 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

You aren't very clear about what you actually want to do in this
question.  But one thing is obviously giving you trouble:  your cube at the
bottom is not a child of the main cube that defines the board.  Attachments
work by being children of other objects.  So for example:

include <BOSL2/std.scad>

MCUboardXYZ = [ 65.98, 2.025.4, 1.63];
MCUboardHoleOffsetsXY = [25.4
[2.505,2-.09994], 25.4*[2.51,2-1.89494]];
MCUboardHoleD = 0.125*25.4;
MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25];
MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0];

MCUboardBOSL2();

module MCUboardBOSL2()
{
diff("holes")
{
cube(MCUboardXYZ, center=false)
{
tag("holes")
for (i=MCUboardHoleOffsetsXY)
{
move( [i.x, i.y, -0.001 ] )
position(FRONT+LEFT+BOTTOM)
cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false);
}
align(BACK+TOP)
cube(MCUBoardPowerSupplyXYZ);
}
}
}

On Mon, Feb 5, 2024 at 8:14 PM Leonard Martin Struttmann via Discuss <
discuss@lists.openscad.org> wrote:

Hello, all!  In an attempt to teach myself about BOSL2 attachables, I am
trying to model a simple PC board.

I create the board and then drill some mounting holes.

Now, how do I add a component and attach it to the PCB?

Obviously, I'm missing some key concepts about how to use attachables.

The attached code illustrates what I have tried and does not work.

Any ideas?  Thanks!  Len

//
---========
include <BOSL2/std.scad>

MCUboardXYZ = [ 65.98, 2.025.4, 1.63];
MCUboardHoleOffsetsXY = [25.4
[2.505,2-.09994], 25.4*[2.51,2-1.89494]];
MCUboardHoleD = 0.125*25.4;
MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25];
MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0];

MCUboardBOSL2();

module MCUboardBOSL2()
{
diff("holes")
{
cube(MCUboardXYZ, center=false)

 tag("holes")
 for (i=MCUboardHoleOffsetsXY)
 {
   move( [i.x, i.y, -0.001 ] )
   position(FRONT+LEFT+BOTTOM)
   cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false);
 }

}

// left(0.34) back(MCUBoardPowerSUpplyOffsets.y)
//  position(BACK+LEFT+BOTTOM)
cube(MCUBoardPowerSupplyXYZ);

}


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


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

Thanks, Adrian! That was exactly the tip that I needed. On Fri, Feb 9, 2024 at 4:16 PM Adrian Mariano via Discuss < discuss@lists.openscad.org> wrote: > You aren't very clear about what you actually want to do in this > question. But one thing is obviously giving you trouble: your cube at the > bottom is not a child of the main cube that defines the board. Attachments > work by being children of other objects. So for example: > > include <BOSL2/std.scad> > > MCUboardXYZ = [ 65.98, 2.0*25.4, 1.63]; > MCUboardHoleOffsetsXY = [25.4*[2.505,2-.09994], 25.4*[2.51,2-1.89494]]; > MCUboardHoleD = 0.125*25.4; > MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25]; > MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0]; > > MCUboardBOSL2(); > > module MCUboardBOSL2() > { > diff("holes") > { > cube(MCUboardXYZ, center=false) > { > tag("holes") > for (i=MCUboardHoleOffsetsXY) > { > move( [i.x, i.y, -0.001 ] ) > position(FRONT+LEFT+BOTTOM) > cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false); > } > align(BACK+TOP) > cube(MCUBoardPowerSupplyXYZ); > } > } > } > > On Mon, Feb 5, 2024 at 8:14 PM Leonard Martin Struttmann via Discuss < > discuss@lists.openscad.org> wrote: > >> Hello, all! In an attempt to teach myself about BOSL2 attachables, I am >> trying to model a simple PC board. >> >> I create the board and then drill some mounting holes. >> >> Now, how do I add a component and attach it to the PCB? >> >> Obviously, I'm missing some key concepts about how to use attachables. >> >> The attached code illustrates what I have tried and does not work. >> >> Any ideas? Thanks! Len >> >> //========================================= >> include <BOSL2/std.scad> >> >> MCUboardXYZ = [ 65.98, 2.0*25.4, 1.63]; >> MCUboardHoleOffsetsXY = [25.4*[2.505,2-.09994], 25.4*[2.51,2-1.89494]]; >> MCUboardHoleD = 0.125*25.4; >> MCUBoardPowerSupplyXYZ = [ 21, 35, 15.25]; >> MCUBoardPowerSUpplyOffsets = [ -0.127, MCUboardXYZ.y-42.672, 0]; >> >> MCUboardBOSL2(); >> >> module MCUboardBOSL2() >> { >> diff("holes") >> { >> cube(MCUboardXYZ, center=false) >> >> tag("holes") >> for (i=MCUboardHoleOffsetsXY) >> { >> move( [i.x, i.y, -0.001 ] ) >> position(FRONT+LEFT+BOTTOM) >> cylinder(h = 2*MCUboardXYZ.z, d=MCUboardHoleD, center=false); >> } >> } >> >> // left(0.34) back(MCUBoardPowerSUpplyOffsets.y) >> // position(BACK+LEFT+BOTTOM) >> cube(MCUBoardPowerSupplyXYZ); >> >> } >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >