discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

questions about best practices with variable scope and how best to access predefined variables

JD
John David
Tue, Mar 12, 2024 2:35 PM

Raymond, part of this is learning OpenSCAD for future use, part of it is
for practical use -- I will be building 20 to 50 "toolholders" for the
office and garage.  There are only a handful that I will want/need to make
more than once.  That said, once you have a tabbed box, and a cleat on a
backer board, that provides enough base functionality to provide the basis
for 3/4 of everything I'll need.

On Tue, Mar 12, 2024 at 7:55 AM Raymond West via Discuss <
discuss@lists.openscad.org> wrote:

I've never needed BOS2L either, although I have asked one or two who
use/contribute wrt the maths that is incorporated within it (I'm finding
that now I'm forgetting more than what I'm learning). It depends what the
objective is, in my case the journey is usually the destination. For
example, I do not need French Cleats, but interesting for me to be  looking
into how I'd approach  it for an imaginary 'user'. I'm not sure if this was
going to be of use, as a  generic program for all materials/method of
construction, but for generating the shape it will do.  For example, in fdm
printing (additive) the fundamental design can be entirely different than
woodwork (subtractive), but the functionality can be the same, and you can
combine both methods to get the best (or worst) of both systems.Maybe wood
for the 'standard' cleating system, and fdm for the specific tool fittings.
On 12/03/2024 00:07, nop head via Discuss wrote:

It is the opposite for me. I can understand basic OpenSCAD code with
translates and rotates but I can't understand any BOSL2 code. I would have
to learn a new language.

On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

BOSL2 may have lots of stuff that is unneeded the vast majority of the
time. However, the basics of BOSL2 have become essential to my use of
OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot,
xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK,
make your code so much more readable that I think it is a huge mistake to
not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would
be incorporated into the base product.

-Bob

On Mar 11, 2024, at 15:35, John David via Discuss <
discuss@lists.openscad.org> wrote:

Thank you, Ray,

I have seen a couple of the videos that "A Glimpse Inside" guy does, and
as I start building my toolholders I will likely go back and watch them
again in the future for ideas.  You are right.  Using BOSL2, or any of this
advanced stuff, is gross overkill.  I had already used OpenSCAD to model a
conventional solid cleat, as well as the simpler thin-cleats like in the
video.  I spent way too much time learning OpenSCAD syntax and semantics,
building my first couple of toolholders as OpenSCAD assemblies using simple
cube, triangle, calendar, union, difference...  (I hope I am using the
correct terminology).  Anyway, when I started thinking of making
toolholders out of tabbed-boxes is what send me down the current bunny
trail.  I am really only working on this late at night as I am starting to
wind down before I go to bed...  My current status is that I build the
profiles (in 2D), and then can add to them, extrude them, etc.  At this
point, I can parametrically generate the simplest of the thin cleats, with
a foot/standoff, a top(not sure what to best name it), side width, etc.
designs

The next step will be to take one or two of my toolholder designs and
make one or more.  My first modeled toolholder, which I have not made yet,
is for a lasercut Kobalt 24v charging station.  A charger is vertically
mounted on the top, there is room for 4 full sized batteries to slide and
lock into place, an open space in the back for the power cord, and the
bottom is flat so it can be carried around and set down on a work table.  I
even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a
small finishing nail to act as alignment pin.  With any luck, that will
work, but it is a good learning exercise.  The one thing I have not figured
out yet is how to modify the cleat so that it also functions as an
erstwhile handle.

Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still
learning the OpenSCAD syntax and I came across heatmap before I came across
advanced associative arrays and structs.

Thanks all for the suggesting and feedback.

On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

Hashmap may be overkill here. Why not use structs instead?  I think they
have some error checking features you won’t get with hashmap to prevent
creation of incorrect fields.

On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

On 3/10/2024 6:00 PM, John David wrote:

OK.  It is starting to take shape.  What I did was to build a named
parameter list that looks like:

 [["cleat","type",type],
  ["cleat","thickness",thickness],
  ["cleat","width",width],
  ["cleat","chamfer",chamfer],
  ["cleat","kerf",kerf],
  ["cleat","angle",angle],
  ["cleat","profile",_fc_cleat_profile

(width,thickness,chamfer,angle,kerf)]];

That can work.  One of these days we'll get PR#4478 in and we'll have a
more concise syntax for this kind of thing.

I am confused about the warnings that are being generated by the
search.  Anyone have suggestions on how to fix those?

Older versions gave warnings when search() did not find a match.
Current development snapshots do not.

[...] I like some of the [BOSL2] functionality with the hashmap
(specifically del and additems).

Note that those functions do not modify existing hashmaps; they create
new hashmaps with the changes requested.  Again, OpenSCAD variables are
immutable, and that includes arrays.


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


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


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

Raymond, part of this is learning OpenSCAD for future use, part of it is for practical use -- I will be building 20 to 50 "toolholders" for the office and garage. There are only a handful that I will want/need to make more than once. That said, once you have a tabbed box, and a cleat on a backer board, that provides enough base functionality to provide the basis for 3/4 of everything I'll need. On Tue, Mar 12, 2024 at 7:55 AM Raymond West via Discuss < discuss@lists.openscad.org> wrote: > I've never needed BOS2L either, although I have asked one or two who > use/contribute wrt the maths that is incorporated within it (I'm finding > that now I'm forgetting more than what I'm learning). It depends what the > objective is, in my case the journey is usually the destination. For > example, I do not need French Cleats, but interesting for me to be looking > into how I'd approach it for an imaginary 'user'. I'm not sure if this was > going to be of use, as a generic program for all materials/method of > construction, but for generating the shape it will do. For example, in fdm > printing (additive) the fundamental design can be entirely different than > woodwork (subtractive), but the functionality can be the same, and you can > combine both methods to get the best (or worst) of both systems.Maybe wood > for the 'standard' cleating system, and fdm for the specific tool fittings. > On 12/03/2024 00:07, nop head via Discuss wrote: > > It is the opposite for me. I can understand basic OpenSCAD code with > translates and rotates but I can't understand any BOSL2 code. I would have > to learn a new language. > > On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss < > discuss@lists.openscad.org> wrote: > >> BOSL2 may have lots of stuff that is unneeded the vast majority of the >> time. However, the basics of BOSL2 have become essential to my use of >> OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot, >> xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK, >> make your code so much more readable that I think it is a huge mistake to >> not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would >> be incorporated into the base product. >> >> -Bob >> >> On Mar 11, 2024, at 15:35, John David via Discuss < >> discuss@lists.openscad.org> wrote: >> >> Thank you, Ray, >> >> I have seen a couple of the videos that "A Glimpse Inside" guy does, and >> as I start building my toolholders I will likely go back and watch them >> again in the future for ideas. You are right. Using BOSL2, or any of this >> advanced stuff, is gross overkill. I had already used OpenSCAD to model a >> conventional solid cleat, as well as the simpler thin-cleats like in the >> video. I spent *way* too much time learning OpenSCAD syntax and semantics, >> building my first couple of toolholders as OpenSCAD assemblies using simple >> cube, triangle, calendar, union, difference... (I hope I am using the >> correct terminology). Anyway, when I started thinking of making >> toolholders out of tabbed-boxes is what send me down the current bunny >> trail. I am really only working on this late at night as I am starting to >> wind down before I go to bed... My current status is that I build the >> profiles (in 2D), and then can add to them, extrude them, etc. At this >> point, I can parametrically generate the simplest of the thin cleats, with >> a foot/standoff, a top(not sure what to best name it), side width, etc. >> designs >> >> The next step will be to take one or two of my toolholder designs and >> make one or more. My first modeled toolholder, which I have not made yet, >> is for a lasercut Kobalt 24v charging station. A charger is vertically >> mounted on the top, there is room for 4 full sized batteries to slide and >> lock into place, an open space in the back for the power cord, and the >> bottom is flat so it can be carried around and set down on a work table. I >> even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a >> small finishing nail to act as alignment pin. With any luck, that will >> work, but it is a good learning exercise. The one thing I have not figured >> out yet is how to modify the cleat so that it also functions as an >> erstwhile handle. >> >> Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still >> learning the OpenSCAD syntax and I came across heatmap before I came across >> advanced associative arrays and structs. >> >> Thanks all for the suggesting and feedback. >> >> On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> Hashmap may be overkill here. Why not use structs instead? I think they >>> have some error checking features you won’t get with hashmap to prevent >>> creation of incorrect fields. >>> >>> On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> On 3/10/2024 6:00 PM, John David wrote: >>>> >>>> OK. It is starting to take shape. What I did was to build a named >>>> parameter list that looks like: >>>> >>>> [["cleat","type",type], >>>> ["cleat","thickness",thickness], >>>> ["cleat","width",width], >>>> ["cleat","chamfer",chamfer], >>>> ["cleat","kerf",kerf], >>>> ["cleat","angle",angle], >>>> ["cleat","profile",_fc_cleat_profile >>>> (width,thickness,chamfer,angle,kerf)]]; >>>> >>>> >>>> That can work. One of these days we'll get PR#4478 in and we'll have a >>>> more concise syntax for this kind of thing. >>>> >>>> I am confused about the warnings that are being generated by the >>>> search. Anyone have suggestions on how to fix those? >>>> >>>> >>>> Older versions gave warnings when search() did not find a match. >>>> Current development snapshots do not. >>>> >>>> [...] I like some of the [BOSL2] functionality with the hashmap >>>> (specifically del and additems). >>>> >>>> >>>> Note that those functions do not modify existing hashmaps; they create >>>> new hashmaps with the changes requested. Again, OpenSCAD variables are >>>> immutable, and that includes arrays. >>>> >>>> _______________________________________________ >>>> 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 >>> >> _______________________________________________ >> 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 >> > > _______________________________________________ > 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 >
BC
Bob Carlson
Tue, Mar 12, 2024 11:33 PM

That comment is difficult to understand unless perhaps you have spent no time looking at it.

First some basic facts.

  • Standard OS code still works in every instance I’m aware of.
  • the basic 2D and 3D shape modules still work but have added arguments that you need not use, but anchor is really useful.

The new translate and rotate modules up, down, left, right, fwd, and back, xrot, yrot, and zrot. All are very intuitive and most of all, readable. They are also more writable, with fewer keystrokes.

  • Up and down are translates on the Z axis. Up(a) I equivalent to translate([0, 0, a]). I think most will find "up" to be more readable.

  • Right and left move on the x-axis. When dealing with 2D it’ clear that positive x is right and negative x is left. Again, a lot more readable than translate([a, 0, 0]).

  • When you get to the Y axis, back must be +y and fwd, -y. This seems odd until you look ate the 3D rendering with the +X on the right. Then it makes perfect sense.

  • xrot, yrot and zrot are simply rotations around a single axis, xrot(a) is equivalent to rotate([a, 0, 0]). I find them way more readable and writable, extra punctuation and extra zeros.

  • I am better than average at visualization but I cannot visualize rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which is the equivalent.

  • What if you actually want xrot(a) yrot(b) zrot(c), which is different? The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]). Not easily readable.

Xcyl, ycyl and zcyl are just cylinders whose height is along the named dimension.

  • Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0, 90, 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise.

Attachability in BOSL2 is complicated  and I rarely use it. However, anchors are the basis of attachability and I use them probably 95% of the time I create a 2D or 3D shape.

  • an anchor is a place on the created shape
  • TOP and BOTTOM are you guessed it, the top and bottom of the shape. Likewise for LEFT, RIGHT, FRONT and BACK.
  • When you say cube([10, 20 30], anchor = TOP), the top center of the cube placed at the origin, [0, 0, 0].
  • These anchors are additive, so you can say cube([10, 20 30], anchor = TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y, -x) quadrant.
  • Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0, 0, -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D vector form because it makes sense to me in the particular context.

Everything above I learned in about 10 minutes I think. It makes my code much easier to read and faster to write. Probably 90% of my use of BOSL2 is this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library. I have no idea if the two libraries are compatible.

There is a lot of other stuff in BOSL2 that you can find when you need it like shapes with chamfering and rounding and so on, but you can ignore it until you need it.

I harp on readability here. Decades ago I settled on that as the priority when I write code. You write it once but you read it many times. I was reminded of this recently. When I got my first 3D printer about 3 years ago I put aside an IOS app I was working in Xcode and Swift. I recently pulled it out and began working on it again. Boy did that remind me how important readability and comments are.

-Bob

On Mar 11, 2024, at 17:07, nop head via Discuss discuss@lists.openscad.org wrote:

It is the opposite for me. I can understand basic OpenSCAD code with translates and rotates but I can't understand any BOSL2 code. I would have to learn a new language.

On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

BOSL2 may have lots of stuff that is unneeded the vast majority of the time. However, the basics of BOSL2 have become essential to my use of OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot, xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK, make your code so much more readable that I think it is a huge mistake to not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would be incorporated into the base product.

-Bob

On Mar 11, 2024, at 15:35, John David via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Thank you, Ray,

I have seen a couple of the videos that "A Glimpse Inside" guy does, and as I start building my toolholders I will likely go back and watch them again in the future for ideas.  You are right.  Using BOSL2, or any of this advanced stuff, is gross overkill.  I had already used OpenSCAD to model a conventional solid cleat, as well as the simpler thin-cleats like in the video.  I spent way too much time learning OpenSCAD syntax and semantics, building my first couple of toolholders as OpenSCAD assemblies using simple cube, triangle, calendar, union, difference...  (I hope I am using the correct terminology).  Anyway, when I started thinking of making toolholders out of tabbed-boxes is what send me down the current bunny trail.  I am really only working on this late at night as I am starting to wind down before I go to bed...  My current status is that I build the profiles (in 2D), and then can add to them, extrude them, etc.  At this point, I can parametrically generate the simplest of the thin cleats, with a foot/standoff, a top(not sure what to best name it), side width, etc.  designs

The next step will be to take one or two of my toolholder designs and make one or more.  My first modeled toolholder, which I have not made yet, is for a lasercut Kobalt 24v charging station.  A charger is vertically mounted on the top, there is room for 4 full sized batteries to slide and lock into place, an open space in the back for the power cord, and the bottom is flat so it can be carried around and set down on a work table.  I even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a small finishing nail to act as alignment pin.  With any luck, that will work, but it is a good learning exercise.  The one thing I have not figured out yet is how to modify the cleat so that it also functions as an erstwhile handle.

Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still learning the OpenSCAD syntax and I came across heatmap before I came across advanced associative arrays and structs.

Thanks all for the suggesting and feedback.

On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Hashmap may be overkill here. Why not use structs instead?  I think they have some error checking features you won’t get with hashmap to prevent creation of incorrect fields.

On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

On 3/10/2024 6:00 PM, John David wrote:

OK.  It is starting to take shape.  What I did was to build a named parameter list that looks like:

 [["cleat","type",type],
  ["cleat","thickness",thickness],
  ["cleat","width",width],
  ["cleat","chamfer",chamfer],
  ["cleat","kerf",kerf],
  ["cleat","angle",angle],
  ["cleat","profile",_fc_cleat_profile (width,thickness,chamfer,angle,kerf)]];

That can work.  One of these days we'll get PR#4478 in and we'll have a more concise syntax for this kind of thing.

I am confused about the warnings that are being generated by the search.  Anyone have suggestions on how to fix those?

Older versions gave warnings when search() did not find a match.  Current development snapshots do not.

[...] I like some of the [BOSL2] functionality with the hashmap (specifically del and additems).

Note that those functions do not modify existing hashmaps; they create new hashmaps with the changes requested.  Again, OpenSCAD variables are immutable, and that includes arrays.


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


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


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


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


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

That comment is difficult to understand unless perhaps you have spent no time looking at it. First some basic facts. - Standard OS code still works in every instance I’m aware of. - the basic 2D and 3D shape modules still work but have added arguments that you need not use, but anchor is really useful. The new translate and rotate modules up, down, left, right, fwd, and back, xrot, yrot, and zrot. All are very intuitive and most of all, readable. They are also more writable, with fewer keystrokes. - Up and down are translates on the Z axis. Up(a) I equivalent to translate([0, 0, a]). I think most will find "up" to be more readable. - Right and left move on the x-axis. When dealing with 2D it’ clear that positive x is right and negative x is left. Again, a lot more readable than translate([a, 0, 0]). - When you get to the Y axis, back must be +y and fwd, -y. This seems odd until you look ate the 3D rendering with the +X on the right. Then it makes perfect sense. - xrot, yrot and zrot are simply rotations around a single axis, xrot(a) is equivalent to rotate([a, 0, 0]). I find them way more readable and writable, extra punctuation and extra zeros. - I am better than average at visualization but I cannot visualize rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which is the equivalent. - What if you actually want xrot(a) yrot(b) zrot(c), which is different? The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]). Not easily readable. Xcyl, ycyl and zcyl are just cylinders whose height is along the named dimension. - Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0, 90, 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise. Attachability in BOSL2 is complicated and I rarely use it. However, anchors are the basis of attachability and I use them probably 95% of the time I create a 2D or 3D shape. - an anchor is a place on the created shape - TOP and BOTTOM are you guessed it, the top and bottom of the shape. Likewise for LEFT, RIGHT, FRONT and BACK. - When you say cube([10, 20 30], anchor = TOP), the top center of the cube placed at the origin, [0, 0, 0]. - These anchors are additive, so you can say cube([10, 20 30], anchor = TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y, -x) quadrant. - Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0, 0, -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D vector form because it makes sense to me in the particular context. Everything above I learned in about 10 minutes I think. It makes my code much easier to read and faster to write. Probably 90% of my use of BOSL2 is this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library. I have no idea if the two libraries are compatible. There is a lot of other stuff in BOSL2 that you can find when you need it like shapes with chamfering and rounding and so on, but you can ignore it until you need it. I harp on readability here. Decades ago I settled on that as the priority when I write code. You write it once but you read it many times. I was reminded of this recently. When I got my first 3D printer about 3 years ago I put aside an IOS app I was working in Xcode and Swift. I recently pulled it out and began working on it again. Boy did that remind me how important readability and comments are. -Bob > On Mar 11, 2024, at 17:07, nop head via Discuss <discuss@lists.openscad.org> wrote: > > It is the opposite for me. I can understand basic OpenSCAD code with translates and rotates but I can't understand any BOSL2 code. I would have to learn a new language. > > On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >> BOSL2 may have lots of stuff that is unneeded the vast majority of the time. However, the basics of BOSL2 have become essential to my use of OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot, xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK, make your code so much more readable that I think it is a huge mistake to not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would be incorporated into the base product. >> >> -Bob >> >>> On Mar 11, 2024, at 15:35, John David via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>> >>> Thank you, Ray, >>> >>> I have seen a couple of the videos that "A Glimpse Inside" guy does, and as I start building my toolholders I will likely go back and watch them again in the future for ideas. You are right. Using BOSL2, or any of this advanced stuff, is gross overkill. I had already used OpenSCAD to model a conventional solid cleat, as well as the simpler thin-cleats like in the video. I spent *way* too much time learning OpenSCAD syntax and semantics, building my first couple of toolholders as OpenSCAD assemblies using simple cube, triangle, calendar, union, difference... (I hope I am using the correct terminology). Anyway, when I started thinking of making toolholders out of tabbed-boxes is what send me down the current bunny trail. I am really only working on this late at night as I am starting to wind down before I go to bed... My current status is that I build the profiles (in 2D), and then can add to them, extrude them, etc. At this point, I can parametrically generate the simplest of the thin cleats, with a foot/standoff, a top(not sure what to best name it), side width, etc. designs >>> >>> The next step will be to take one or two of my toolholder designs and make one or more. My first modeled toolholder, which I have not made yet, is for a lasercut Kobalt 24v charging station. A charger is vertically mounted on the top, there is room for 4 full sized batteries to slide and lock into place, an open space in the back for the power cord, and the bottom is flat so it can be carried around and set down on a work table. I even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a small finishing nail to act as alignment pin. With any luck, that will work, but it is a good learning exercise. The one thing I have not figured out yet is how to modify the cleat so that it also functions as an erstwhile handle. >>> >>> Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still learning the OpenSCAD syntax and I came across heatmap before I came across advanced associative arrays and structs. >>> >>> Thanks all for the suggesting and feedback. >>> >>> On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>> Hashmap may be overkill here. Why not use structs instead? I think they have some error checking features you won’t get with hashmap to prevent creation of incorrect fields. >>>> >>>> On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>>> On 3/10/2024 6:00 PM, John David wrote: >>>>>> OK. It is starting to take shape. What I did was to build a named parameter list that looks like: >>>>>> >>>>>> [["cleat","type",type], >>>>>> ["cleat","thickness",thickness], >>>>>> ["cleat","width",width], >>>>>> ["cleat","chamfer",chamfer], >>>>>> ["cleat","kerf",kerf], >>>>>> ["cleat","angle",angle], >>>>>> ["cleat","profile",_fc_cleat_profile (width,thickness,chamfer,angle,kerf)]]; >>>>> >>>>> That can work. One of these days we'll get PR#4478 in and we'll have a more concise syntax for this kind of thing. >>>>> >>>>>> I am confused about the warnings that are being generated by the search. Anyone have suggestions on how to fix those? >>>>> >>>>> Older versions gave warnings when search() did not find a match. Current development snapshots do not. >>>>> >>>>>> [...] I like some of the [BOSL2] functionality with the hashmap (specifically del and additems). >>>>> >>>>> Note that those functions do not modify existing hashmaps; they create new hashmaps with the changes requested. Again, OpenSCAD variables are immutable, and that includes arrays. >>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JD
John David
Wed, Mar 13, 2024 1:47 AM

Bob, I am not sure what I wrote that you are objecting to (assuming the
objectionable comment is something I wrote).  I agree with most, if not
all, of what you have said.  I have yet to learn and use "attach".  I think
I am going to like it ;-)

With regards to readability and comments, I would also add using the
simplest standard features you can. Two of my funniest stories there are:

  • My first paid programming job was helping to write the OS for an embedded
    environmental monitor (circa 1979).  The company that commissioned the
    project was to cheap to purchase an assembled for it (which cost $6,000 in
    1975 dollars), so we hand assembled the code into HEX...  Skip forward
    maybe 5 years later, a friend who took over the project and built some of
    his own embedded projects surrounding the same RCA-1802 chip (which BTW is
    one of the same chips in the Hubble imager).  He was fighting with
    maintaining some code, and I bet him a case of Coca-Cola that I could write
    him a fully relocatable macro assembler for that architecture in 24 hours
    flat.  Well, I ran into a bug, and I blew through the 24hr mark, but I had
    it running by the 36hr mark.  He paid me the case of coke anyway, and used
    it for years... I wrote this in strict ANSI-compliant C, with a few dozen
    test-driven development sanity checks...  Skip forward to 1999 (pre-Y2K),
    and my buddy needed to fix a Y2K bug in a couple of the embedded machines.
    He called me up with some trepidation to bounce a few ideas off me.  He
    then recompiled the 15 year-old assembler, made the changes to the assembly
    code, ran it through and reinstalled the executables on the machines in a
    couple of hours.  He bought me another case of coke just to say thanks ;-)

  • the other story is about a PhD student I knew growing up, who developed a
    geometry compiler called G which was intended to provide low-level C-like
    geometric functionality similar to OpenSCAD primitives.  The heart of the
    compiler came down to about 6 lines of code that was so obfuscated, that I
    spent several months trying to wrap my head around them to fix a semantic
    bug and extend the functionality.  I gave up, but it was a readability
    lesson for me in my tender youth...

I am a strong proponent of eXtreme Programming (XP) and various literate
programming offshoots.  I really love how you can write your comments in
python and have the doc strings serve as hoverable documentation...

I'll go back and look at some of the shortcuts (like zrot, dire3ctions, and
attachment).

On Tue, Mar 12, 2024 at 7:33 PM Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

That comment is difficult to understand unless perhaps you have spent no
time looking at it.

First some basic facts.

  • Standard OS code still works in every instance I’m aware of.
  • the basic 2D and 3D shape modules still work but have added arguments
    that you need not use, but anchor is really useful.

The new translate and rotate modules up, down, left, right, fwd, and back,
xrot, yrot, and zrot. All are very intuitive and most of all, readable.
They are also more writable, with fewer keystrokes.

  • Up and down are translates on the Z axis. Up(a) I equivalent to
    translate([0, 0, a]). I think most will find "up" to be more readable.

  • Right and left move on the x-axis. When dealing with 2D it’ clear that
    positive x is right and negative x is left. Again, a lot more readable than
    translate([a, 0, 0]).

  • When you get to the Y axis, back must be +y and fwd, -y. This seems odd
    until you look ate the 3D rendering with the +X on the right. Then it makes
    perfect sense.

  • xrot, yrot and zrot are simply rotations around a single axis, xrot(a)
    is equivalent to rotate([a, 0, 0]). I find them way more readable and
    writable, extra punctuation and extra zeros.

  • I am better than average at visualization but I cannot visualize
    rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which
    is the equivalent.

  • What if you actually want xrot(a) yrot(b) zrot(c), which is different?
    The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]).
    Not easily readable.

Xcyl, ycyl and zcyl are just cylinders whose height is along the named
dimension.

  • Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0, 90,
    0]) cylinder(). Way easier to read or write. Ycyl left as an exercise.

Attachability in BOSL2 is complicated  and I rarely use it. However,
anchors are the basis of attachability and I use them probably 95% of the
time I create a 2D or 3D shape.

  • an anchor is a place on the created shape
  • TOP and BOTTOM are you guessed it, the top and bottom of the shape.
    Likewise for LEFT, RIGHT, FRONT and BACK.
  • When you say cube([10, 20 30], anchor = TOP), the top center of the cube
    placed at the origin, [0, 0, 0].
  • These anchors are additive, so you can say cube([10, 20 30], anchor =
    TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y,
    -x) quadrant.
  • Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0, 0,
    -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D vector
    form because it makes sense to me in the particular context.

Everything above I learned in about 10 minutes I think. It makes my code
much easier to read and faster to write. Probably 90% of my use of BOSL2 is
this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library.
I have no idea if the two libraries are compatible.

There is a lot of other stuff in BOSL2 that you can find when you need it
like shapes with chamfering and rounding and so on, but you can ignore it
until you need it.

I harp on readability here. Decades ago I settled on that as the priority
when I write code. You write it once but you read it many times. I was
reminded of this recently. When I got my first 3D printer about 3 years ago
I put aside an IOS app I was working in Xcode and Swift. I recently pulled
it out and began working on it again. Boy did that remind me how important
readability and comments are.

-Bob

On Mar 11, 2024, at 17:07, nop head via Discuss <
discuss@lists.openscad.org> wrote:

It is the opposite for me. I can understand basic OpenSCAD code with
translates and rotates but I can't understand any BOSL2 code. I would have
to learn a new language.

On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

BOSL2 may have lots of stuff that is unneeded the vast majority of the
time. However, the basics of BOSL2 have become essential to my use of
OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot,
xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK,
make your code so much more readable that I think it is a huge mistake to
not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would
be incorporated into the base product.

-Bob

On Mar 11, 2024, at 15:35, John David via Discuss <
discuss@lists.openscad.org> wrote:

Thank you, Ray,

I have seen a couple of the videos that "A Glimpse Inside" guy does, and
as I start building my toolholders I will likely go back and watch them
again in the future for ideas.  You are right.  Using BOSL2, or any of this
advanced stuff, is gross overkill.  I had already used OpenSCAD to model a
conventional solid cleat, as well as the simpler thin-cleats like in the
video.  I spent way too much time learning OpenSCAD syntax and semantics,
building my first couple of toolholders as OpenSCAD assemblies using simple
cube, triangle, calendar, union, difference...  (I hope I am using the
correct terminology).  Anyway, when I started thinking of making
toolholders out of tabbed-boxes is what send me down the current bunny
trail.  I am really only working on this late at night as I am starting to
wind down before I go to bed...  My current status is that I build the
profiles (in 2D), and then can add to them, extrude them, etc.  At this
point, I can parametrically generate the simplest of the thin cleats, with
a foot/standoff, a top(not sure what to best name it), side width, etc.
designs

The next step will be to take one or two of my toolholder designs and
make one or more.  My first modeled toolholder, which I have not made yet,
is for a lasercut Kobalt 24v charging station.  A charger is vertically
mounted on the top, there is room for 4 full sized batteries to slide and
lock into place, an open space in the back for the power cord, and the
bottom is flat so it can be carried around and set down on a work table.  I
even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a
small finishing nail to act as alignment pin.  With any luck, that will
work, but it is a good learning exercise.  The one thing I have not figured
out yet is how to modify the cleat so that it also functions as an
erstwhile handle.

Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still
learning the OpenSCAD syntax and I came across heatmap before I came across
advanced associative arrays and structs.

Thanks all for the suggesting and feedback.

On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

Hashmap may be overkill here. Why not use structs instead?  I think they
have some error checking features you won’t get with hashmap to prevent
creation of incorrect fields.

On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

On 3/10/2024 6:00 PM, John David wrote:

OK.  It is starting to take shape.  What I did was to build a named
parameter list that looks like:

 [["cleat","type",type],
  ["cleat","thickness",thickness],
  ["cleat","width",width],
  ["cleat","chamfer",chamfer],
  ["cleat","kerf",kerf],
  ["cleat","angle",angle],
  ["cleat","profile",_fc_cleat_profile

(width,thickness,chamfer,angle,kerf)]];

That can work.  One of these days we'll get PR#4478 in and we'll have a
more concise syntax for this kind of thing.

I am confused about the warnings that are being generated by the
search.  Anyone have suggestions on how to fix those?

Older versions gave warnings when search() did not find a match.
Current development snapshots do not.

[...] I like some of the [BOSL2] functionality with the hashmap
(specifically del and additems).

Note that those functions do not modify existing hashmaps; they create
new hashmaps with the changes requested.  Again, OpenSCAD variables are
immutable, and that includes arrays.


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


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


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

Bob, I am not sure what I wrote that you are objecting to (assuming the objectionable comment is something I wrote). I agree with most, if not all, of what you have said. I have yet to learn and use "attach". I think I am going to like it ;-) With regards to readability and comments, I would also add using the simplest standard features you can. Two of my funniest stories there are: * My first paid programming job was helping to write the OS for an embedded environmental monitor (circa 1979). The company that commissioned the project was to cheap to purchase an assembled for it (which cost $6,000 in 1975 dollars), so we hand assembled the code into HEX... Skip forward maybe 5 years later, a friend who took over the project and built some of his own embedded projects surrounding the same RCA-1802 chip (which BTW is one of the same chips in the Hubble imager). He was fighting with maintaining some code, and I bet him a case of Coca-Cola that I could write him a fully relocatable macro assembler for that architecture in 24 hours flat. Well, I ran into a bug, and I blew through the 24hr mark, but I had it running by the 36hr mark. He paid me the case of coke anyway, and used it for years... I wrote this in strict ANSI-compliant C, with a few dozen test-driven development sanity checks... Skip forward to 1999 (pre-Y2K), and my buddy needed to fix a Y2K bug in a couple of the embedded machines. He called me up with some trepidation to bounce a few ideas off me. He then recompiled the 15 year-old assembler, made the changes to the assembly code, ran it through and reinstalled the executables on the machines in a couple of hours. He bought me another case of coke just to say thanks ;-) * the other story is about a PhD student I knew growing up, who developed a geometry compiler called G which was intended to provide low-level C-like geometric functionality similar to OpenSCAD primitives. The heart of the compiler came down to about 6 lines of code that was so obfuscated, that I spent several months trying to wrap my head around them to fix a semantic bug and extend the functionality. I gave up, but it was a readability lesson for me in my tender youth... I am a strong proponent of eXtreme Programming (XP) and various literate programming offshoots. I really love how you can write your comments in python and have the doc strings serve as hoverable documentation... I'll go back and look at some of the shortcuts (like zrot, dire3ctions, and attachment). On Tue, Mar 12, 2024 at 7:33 PM Bob Carlson via Discuss < discuss@lists.openscad.org> wrote: > That comment is difficult to understand unless perhaps you have spent no > time looking at it. > > First some basic facts. > - Standard OS code still works in every instance I’m aware of. > - the basic 2D and 3D shape modules still work but have added arguments > that you need not use, but anchor is really useful. > > The new translate and rotate modules up, down, left, right, fwd, and back, > xrot, yrot, and zrot. All are very intuitive and most of all, readable. > They are also more writable, with fewer keystrokes. > - Up and down are translates on the Z axis. Up(a) I equivalent to > translate([0, 0, a]). I think most will find "up" to be more readable. > - Right and left move on the x-axis. When dealing with 2D it’ clear that > positive x is right and negative x is left. Again, a lot more readable than > translate([a, 0, 0]). > - When you get to the Y axis, back must be +y and fwd, -y. This seems odd > until you look ate the 3D rendering with the +X on the right. Then it makes > perfect sense. > > - xrot, yrot and zrot are simply rotations around a single axis, xrot(a) > is equivalent to rotate([a, 0, 0]). I find them way more readable and > writable, extra punctuation and extra zeros. > - I am better than average at visualization but I cannot visualize > rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which > is the equivalent. > - What if you actually want xrot(a) yrot(b) zrot(c), which is different? > The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]). > Not easily readable. > > Xcyl, ycyl and zcyl are just cylinders whose height is along the named > dimension. > - Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0, 90, > 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise. > > Attachability in BOSL2 is complicated and I rarely use it. However, > anchors are the basis of attachability and I use them probably 95% of the > time I create a 2D or 3D shape. > - an anchor is a place on the created shape > - TOP and BOTTOM are you guessed it, the top and bottom of the shape. > Likewise for LEFT, RIGHT, FRONT and BACK. > - When you say cube([10, 20 30], anchor = TOP), the top center of the cube > placed at the origin, [0, 0, 0]. > - These anchors are additive, so you can say cube([10, 20 30], anchor = > TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y, > -x) quadrant. > - Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0, 0, > -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D vector > form because it makes sense to me in the particular context. > > Everything above I learned in about 10 minutes I think. It makes my code > much easier to read and faster to write. Probably 90% of my use of BOSL2 is > this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library. > I have no idea if the two libraries are compatible. > > There is a lot of other stuff in BOSL2 that you can find when you need it > like shapes with chamfering and rounding and so on, but you can ignore it > until you need it. > > I harp on readability here. Decades ago I settled on that as the priority > when I write code. You write it once but you read it many times. I was > reminded of this recently. When I got my first 3D printer about 3 years ago > I put aside an IOS app I was working in Xcode and Swift. I recently pulled > it out and began working on it again. Boy did that remind me how important > readability and comments are. > > -Bob > > > On Mar 11, 2024, at 17:07, nop head via Discuss < > discuss@lists.openscad.org> wrote: > > It is the opposite for me. I can understand basic OpenSCAD code with > translates and rotates but I can't understand any BOSL2 code. I would have > to learn a new language. > > On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss < > discuss@lists.openscad.org> wrote: > >> BOSL2 may have lots of stuff that is unneeded the vast majority of the >> time. However, the basics of BOSL2 have become essential to my use of >> OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot, >> xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK, >> make your code so much more readable that I think it is a huge mistake to >> not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would >> be incorporated into the base product. >> >> -Bob >> >> On Mar 11, 2024, at 15:35, John David via Discuss < >> discuss@lists.openscad.org> wrote: >> >> Thank you, Ray, >> >> I have seen a couple of the videos that "A Glimpse Inside" guy does, and >> as I start building my toolholders I will likely go back and watch them >> again in the future for ideas. You are right. Using BOSL2, or any of this >> advanced stuff, is gross overkill. I had already used OpenSCAD to model a >> conventional solid cleat, as well as the simpler thin-cleats like in the >> video. I spent *way* too much time learning OpenSCAD syntax and semantics, >> building my first couple of toolholders as OpenSCAD assemblies using simple >> cube, triangle, calendar, union, difference... (I hope I am using the >> correct terminology). Anyway, when I started thinking of making >> toolholders out of tabbed-boxes is what send me down the current bunny >> trail. I am really only working on this late at night as I am starting to >> wind down before I go to bed... My current status is that I build the >> profiles (in 2D), and then can add to them, extrude them, etc. At this >> point, I can parametrically generate the simplest of the thin cleats, with >> a foot/standoff, a top(not sure what to best name it), side width, etc. >> designs >> >> The next step will be to take one or two of my toolholder designs and >> make one or more. My first modeled toolholder, which I have not made yet, >> is for a lasercut Kobalt 24v charging station. A charger is vertically >> mounted on the top, there is room for 4 full sized batteries to slide and >> lock into place, an open space in the back for the power cord, and the >> bottom is flat so it can be carried around and set down on a work table. I >> even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a >> small finishing nail to act as alignment pin. With any luck, that will >> work, but it is a good learning exercise. The one thing I have not figured >> out yet is how to modify the cleat so that it also functions as an >> erstwhile handle. >> >> Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still >> learning the OpenSCAD syntax and I came across heatmap before I came across >> advanced associative arrays and structs. >> >> Thanks all for the suggesting and feedback. >> >> On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> Hashmap may be overkill here. Why not use structs instead? I think they >>> have some error checking features you won’t get with hashmap to prevent >>> creation of incorrect fields. >>> >>> On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> On 3/10/2024 6:00 PM, John David wrote: >>>> >>>> OK. It is starting to take shape. What I did was to build a named >>>> parameter list that looks like: >>>> >>>> [["cleat","type",type], >>>> ["cleat","thickness",thickness], >>>> ["cleat","width",width], >>>> ["cleat","chamfer",chamfer], >>>> ["cleat","kerf",kerf], >>>> ["cleat","angle",angle], >>>> ["cleat","profile",_fc_cleat_profile >>>> (width,thickness,chamfer,angle,kerf)]]; >>>> >>>> >>>> That can work. One of these days we'll get PR#4478 in and we'll have a >>>> more concise syntax for this kind of thing. >>>> >>>> I am confused about the warnings that are being generated by the >>>> search. Anyone have suggestions on how to fix those? >>>> >>>> >>>> Older versions gave warnings when search() did not find a match. >>>> Current development snapshots do not. >>>> >>>> [...] I like some of the [BOSL2] functionality with the hashmap >>>> (specifically del and additems). >>>> >>>> >>>> Note that those functions do not modify existing hashmaps; they create >>>> new hashmaps with the changes requested. Again, OpenSCAD variables are >>>> immutable, and that includes arrays. >>>> >>>> _______________________________________________ >>>> 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 >>> >> _______________________________________________ >> 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 >> > _______________________________________________ > 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 >
BC
Bob Carlson
Thu, Mar 14, 2024 6:35 PM

I was actually responding to a comment Nop Head had made. No worries though. Sounds like we have a similar background. My first programming job was 1972.

-Bob

On Mar 12, 2024, at 18:47, John David ebo.2112@gmail.com wrote:

Bob, I am not sure what I wrote that you are objecting to (assuming the objectionable comment is something I wrote).  I agree with most, if not all, of what you have said.  I have yet to learn and use "attach".  I think I am going to like it ;-)

With regards to readability and comments, I would also add using the simplest standard features you can. Two of my funniest stories there are:

  • My first paid programming job was helping to write the OS for an embedded environmental monitor (circa 1979).  The company that commissioned the project was to cheap to purchase an assembled for it (which cost $6,000 in 1975 dollars), so we hand assembled the code into HEX...  Skip forward maybe 5 years later, a friend who took over the project and built some of his own embedded projects surrounding the same RCA-1802 chip (which BTW is one of the same chips in the Hubble imager).  He was fighting with maintaining some code, and I bet him a case of Coca-Cola that I could write him a fully relocatable macro assembler for that architecture in 24 hours flat.  Well, I ran into a bug, and I blew through the 24hr mark, but I had it running by the 36hr mark.  He paid me the case of coke anyway, and used it for years... I wrote this in strict ANSI-compliant C, with a few dozen test-driven development sanity checks...  Skip forward to 1999 (pre-Y2K), and my buddy needed to fix a Y2K bug in a couple of the embedded machines.  He called me up with some trepidation to bounce a few ideas off me.  He then recompiled the 15 year-old assembler, made the changes to the assembly code, ran it through and reinstalled the executables on the machines in a couple of hours.  He bought me another case of coke just to say thanks ;-)

  • the other story is about a PhD student I knew growing up, who developed a geometry compiler called G which was intended to provide low-level C-like geometric functionality similar to OpenSCAD primitives.  The heart of the compiler came down to about 6 lines of code that was so obfuscated, that I spent several months trying to wrap my head around them to fix a semantic bug and extend the functionality.  I gave up, but it was a readability lesson for me in my tender youth...

I am a strong proponent of eXtreme Programming (XP) and various literate programming offshoots.  I really love how you can write your comments in python and have the doc strings serve as hoverable documentation...

I'll go back and look at some of the shortcuts (like zrot, dire3ctions, and attachment).

On Tue, Mar 12, 2024 at 7:33 PM Bob Carlson via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

That comment is difficult to understand unless perhaps you have spent no time looking at it.

First some basic facts.

  • Standard OS code still works in every instance I’m aware of.
  • the basic 2D and 3D shape modules still work but have added arguments that you need not use, but anchor is really useful.

The new translate and rotate modules up, down, left, right, fwd, and back, xrot, yrot, and zrot. All are very intuitive and most of all, readable. They are also more writable, with fewer keystrokes.

  • Up and down are translates on the Z axis. Up(a) I equivalent to translate([0, 0, a]). I think most will find "up" to be more readable.

  • Right and left move on the x-axis. When dealing with 2D it’ clear that positive x is right and negative x is left. Again, a lot more readable than translate([a, 0, 0]).

  • When you get to the Y axis, back must be +y and fwd, -y. This seems odd until you look ate the 3D rendering with the +X on the right. Then it makes perfect sense.

  • xrot, yrot and zrot are simply rotations around a single axis, xrot(a) is equivalent to rotate([a, 0, 0]). I find them way more readable and writable, extra punctuation and extra zeros.

  • I am better than average at visualization but I cannot visualize rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which is the equivalent.

  • What if you actually want xrot(a) yrot(b) zrot(c), which is different? The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]). Not easily readable.

Xcyl, ycyl and zcyl are just cylinders whose height is along the named dimension.

  • Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0, 90, 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise.

Attachability in BOSL2 is complicated  and I rarely use it. However, anchors are the basis of attachability and I use them probably 95% of the time I create a 2D or 3D shape.

  • an anchor is a place on the created shape
  • TOP and BOTTOM are you guessed it, the top and bottom of the shape. Likewise for LEFT, RIGHT, FRONT and BACK.
  • When you say cube([10, 20 30], anchor = TOP), the top center of the cube placed at the origin, [0, 0, 0].
  • These anchors are additive, so you can say cube([10, 20 30], anchor = TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y, -x) quadrant.
  • Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0, 0, -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D vector form because it makes sense to me in the particular context.

Everything above I learned in about 10 minutes I think. It makes my code much easier to read and faster to write. Probably 90% of my use of BOSL2 is this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library. I have no idea if the two libraries are compatible.

There is a lot of other stuff in BOSL2 that you can find when you need it like shapes with chamfering and rounding and so on, but you can ignore it until you need it.

I harp on readability here. Decades ago I settled on that as the priority when I write code. You write it once but you read it many times. I was reminded of this recently. When I got my first 3D printer about 3 years ago I put aside an IOS app I was working in Xcode and Swift. I recently pulled it out and began working on it again. Boy did that remind me how important readability and comments are.

-Bob

On Mar 11, 2024, at 17:07, nop head via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

It is the opposite for me. I can understand basic OpenSCAD code with translates and rotates but I can't understand any BOSL2 code. I would have to learn a new language.

On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

BOSL2 may have lots of stuff that is unneeded the vast majority of the time. However, the basics of BOSL2 have become essential to my use of OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot, xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK, make your code so much more readable that I think it is a huge mistake to not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would be incorporated into the base product.

-Bob

On Mar 11, 2024, at 15:35, John David via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Thank you, Ray,

I have seen a couple of the videos that "A Glimpse Inside" guy does, and as I start building my toolholders I will likely go back and watch them again in the future for ideas.  You are right.  Using BOSL2, or any of this advanced stuff, is gross overkill.  I had already used OpenSCAD to model a conventional solid cleat, as well as the simpler thin-cleats like in the video.  I spent way too much time learning OpenSCAD syntax and semantics, building my first couple of toolholders as OpenSCAD assemblies using simple cube, triangle, calendar, union, difference...  (I hope I am using the correct terminology).  Anyway, when I started thinking of making toolholders out of tabbed-boxes is what send me down the current bunny trail.  I am really only working on this late at night as I am starting to wind down before I go to bed...  My current status is that I build the profiles (in 2D), and then can add to them, extrude them, etc.  At this point, I can parametrically generate the simplest of the thin cleats, with a foot/standoff, a top(not sure what to best name it), side width, etc.  designs

The next step will be to take one or two of my toolholder designs and make one or more.  My first modeled toolholder, which I have not made yet, is for a lasercut Kobalt 24v charging station.  A charger is vertically mounted on the top, there is room for 4 full sized batteries to slide and lock into place, an open space in the back for the power cord, and the bottom is flat so it can be carried around and set down on a work table.  I even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a small finishing nail to act as alignment pin.  With any luck, that will work, but it is a good learning exercise.  The one thing I have not figured out yet is how to modify the cleat so that it also functions as an erstwhile handle.

Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still learning the OpenSCAD syntax and I came across heatmap before I came across advanced associative arrays and structs.

Thanks all for the suggesting and feedback.

On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

Hashmap may be overkill here. Why not use structs instead?  I think they have some error checking features you won’t get with hashmap to prevent creation of incorrect fields.

On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org> wrote:

On 3/10/2024 6:00 PM, John David wrote:

OK.  It is starting to take shape.  What I did was to build a named parameter list that looks like:

 [["cleat","type",type],
  ["cleat","thickness",thickness],
  ["cleat","width",width],
  ["cleat","chamfer",chamfer],
  ["cleat","kerf",kerf],
  ["cleat","angle",angle],
  ["cleat","profile",_fc_cleat_profile (width,thickness,chamfer,angle,kerf)]];

That can work.  One of these days we'll get PR#4478 in and we'll have a more concise syntax for this kind of thing.

I am confused about the warnings that are being generated by the search.  Anyone have suggestions on how to fix those?

Older versions gave warnings when search() did not find a match.  Current development snapshots do not.

[...] I like some of the [BOSL2] functionality with the hashmap (specifically del and additems).

Note that those functions do not modify existing hashmaps; they create new hashmaps with the changes requested.  Again, OpenSCAD variables are immutable, and that includes arrays.


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


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


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


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


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


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

I was actually responding to a comment Nop Head had made. No worries though. Sounds like we have a similar background. My first programming job was 1972. -Bob > On Mar 12, 2024, at 18:47, John David <ebo.2112@gmail.com> wrote: > > Bob, I am not sure what I wrote that you are objecting to (assuming the objectionable comment is something I wrote). I agree with most, if not all, of what you have said. I have yet to learn and use "attach". I think I am going to like it ;-) > > With regards to readability and comments, I would also add using the simplest standard features you can. Two of my funniest stories there are: > > * My first paid programming job was helping to write the OS for an embedded environmental monitor (circa 1979). The company that commissioned the project was to cheap to purchase an assembled for it (which cost $6,000 in 1975 dollars), so we hand assembled the code into HEX... Skip forward maybe 5 years later, a friend who took over the project and built some of his own embedded projects surrounding the same RCA-1802 chip (which BTW is one of the same chips in the Hubble imager). He was fighting with maintaining some code, and I bet him a case of Coca-Cola that I could write him a fully relocatable macro assembler for that architecture in 24 hours flat. Well, I ran into a bug, and I blew through the 24hr mark, but I had it running by the 36hr mark. He paid me the case of coke anyway, and used it for years... I wrote this in strict ANSI-compliant C, with a few dozen test-driven development sanity checks... Skip forward to 1999 (pre-Y2K), and my buddy needed to fix a Y2K bug in a couple of the embedded machines. He called me up with some trepidation to bounce a few ideas off me. He then recompiled the 15 year-old assembler, made the changes to the assembly code, ran it through and reinstalled the executables on the machines in a couple of hours. He bought me another case of coke just to say thanks ;-) > > * the other story is about a PhD student I knew growing up, who developed a geometry compiler called G which was intended to provide low-level C-like geometric functionality similar to OpenSCAD primitives. The heart of the compiler came down to about 6 lines of code that was so obfuscated, that I spent several months trying to wrap my head around them to fix a semantic bug and extend the functionality. I gave up, but it was a readability lesson for me in my tender youth... > > I am a strong proponent of eXtreme Programming (XP) and various literate programming offshoots. I really love how you can write your comments in python and have the doc strings serve as hoverable documentation... > > I'll go back and look at some of the shortcuts (like zrot, dire3ctions, and attachment). > > > > On Tue, Mar 12, 2024 at 7:33 PM Bob Carlson via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >> That comment is difficult to understand unless perhaps you have spent no time looking at it. >> >> First some basic facts. >> - Standard OS code still works in every instance I’m aware of. >> - the basic 2D and 3D shape modules still work but have added arguments that you need not use, but anchor is really useful. >> >> The new translate and rotate modules up, down, left, right, fwd, and back, xrot, yrot, and zrot. All are very intuitive and most of all, readable. They are also more writable, with fewer keystrokes. >> - Up and down are translates on the Z axis. Up(a) I equivalent to translate([0, 0, a]). I think most will find "up" to be more readable. >> - Right and left move on the x-axis. When dealing with 2D it’ clear that positive x is right and negative x is left. Again, a lot more readable than translate([a, 0, 0]). >> - When you get to the Y axis, back must be +y and fwd, -y. This seems odd until you look ate the 3D rendering with the +X on the right. Then it makes perfect sense. >> >> - xrot, yrot and zrot are simply rotations around a single axis, xrot(a) is equivalent to rotate([a, 0, 0]). I find them way more readable and writable, extra punctuation and extra zeros. >> - I am better than average at visualization but I cannot visualize rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which is the equivalent. >> - What if you actually want xrot(a) yrot(b) zrot(c), which is different? The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]). Not easily readable. >> >> Xcyl, ycyl and zcyl are just cylinders whose height is along the named dimension. >> - Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0, 90, 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise. >> >> Attachability in BOSL2 is complicated and I rarely use it. However, anchors are the basis of attachability and I use them probably 95% of the time I create a 2D or 3D shape. >> - an anchor is a place on the created shape >> - TOP and BOTTOM are you guessed it, the top and bottom of the shape. Likewise for LEFT, RIGHT, FRONT and BACK. >> - When you say cube([10, 20 30], anchor = TOP), the top center of the cube placed at the origin, [0, 0, 0]. >> - These anchors are additive, so you can say cube([10, 20 30], anchor = TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y, -x) quadrant. >> - Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0, 0, -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D vector form because it makes sense to me in the particular context. >> >> Everything above I learned in about 10 minutes I think. It makes my code much easier to read and faster to write. Probably 90% of my use of BOSL2 is this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library. I have no idea if the two libraries are compatible. >> >> There is a lot of other stuff in BOSL2 that you can find when you need it like shapes with chamfering and rounding and so on, but you can ignore it until you need it. >> >> I harp on readability here. Decades ago I settled on that as the priority when I write code. You write it once but you read it many times. I was reminded of this recently. When I got my first 3D printer about 3 years ago I put aside an IOS app I was working in Xcode and Swift. I recently pulled it out and began working on it again. Boy did that remind me how important readability and comments are. >> >> -Bob >> >> >>> On Mar 11, 2024, at 17:07, nop head via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>> >>> It is the opposite for me. I can understand basic OpenSCAD code with translates and rotates but I can't understand any BOSL2 code. I would have to learn a new language. >>> >>> On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>> BOSL2 may have lots of stuff that is unneeded the vast majority of the time. However, the basics of BOSL2 have become essential to my use of OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot, xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK, make your code so much more readable that I think it is a huge mistake to not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would be incorporated into the base product. >>>> >>>> -Bob >>>> >>>>> On Mar 11, 2024, at 15:35, John David via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>>> >>>>> Thank you, Ray, >>>>> >>>>> I have seen a couple of the videos that "A Glimpse Inside" guy does, and as I start building my toolholders I will likely go back and watch them again in the future for ideas. You are right. Using BOSL2, or any of this advanced stuff, is gross overkill. I had already used OpenSCAD to model a conventional solid cleat, as well as the simpler thin-cleats like in the video. I spent *way* too much time learning OpenSCAD syntax and semantics, building my first couple of toolholders as OpenSCAD assemblies using simple cube, triangle, calendar, union, difference... (I hope I am using the correct terminology). Anyway, when I started thinking of making toolholders out of tabbed-boxes is what send me down the current bunny trail. I am really only working on this late at night as I am starting to wind down before I go to bed... My current status is that I build the profiles (in 2D), and then can add to them, extrude them, etc. At this point, I can parametrically generate the simplest of the thin cleats, with a foot/standoff, a top(not sure what to best name it), side width, etc. designs >>>>> >>>>> The next step will be to take one or two of my toolholder designs and make one or more. My first modeled toolholder, which I have not made yet, is for a lasercut Kobalt 24v charging station. A charger is vertically mounted on the top, there is room for 4 full sized batteries to slide and lock into place, an open space in the back for the power cord, and the bottom is flat so it can be carried around and set down on a work table. I even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a small finishing nail to act as alignment pin. With any luck, that will work, but it is a good learning exercise. The one thing I have not figured out yet is how to modify the cleat so that it also functions as an erstwhile handle. >>>>> >>>>> Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still learning the OpenSCAD syntax and I came across heatmap before I came across advanced associative arrays and structs. >>>>> >>>>> Thanks all for the suggesting and feedback. >>>>> >>>>> On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>>>> Hashmap may be overkill here. Why not use structs instead? I think they have some error checking features you won’t get with hashmap to prevent creation of incorrect fields. >>>>>> >>>>>> On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org>> wrote: >>>>>>> On 3/10/2024 6:00 PM, John David wrote: >>>>>>>> OK. It is starting to take shape. What I did was to build a named parameter list that looks like: >>>>>>>> >>>>>>>> [["cleat","type",type], >>>>>>>> ["cleat","thickness",thickness], >>>>>>>> ["cleat","width",width], >>>>>>>> ["cleat","chamfer",chamfer], >>>>>>>> ["cleat","kerf",kerf], >>>>>>>> ["cleat","angle",angle], >>>>>>>> ["cleat","profile",_fc_cleat_profile (width,thickness,chamfer,angle,kerf)]]; >>>>>>> >>>>>>> That can work. One of these days we'll get PR#4478 in and we'll have a more concise syntax for this kind of thing. >>>>>>> >>>>>>>> I am confused about the warnings that are being generated by the search. Anyone have suggestions on how to fix those? >>>>>>> >>>>>>> Older versions gave warnings when search() did not find a match. Current development snapshots do not. >>>>>>> >>>>>>>> [...] I like some of the [BOSL2] functionality with the hashmap (specifically del and additems). >>>>>>> >>>>>>> Note that those functions do not modify existing hashmaps; they create new hashmaps with the changes requested. Again, OpenSCAD variables are immutable, and that includes arrays. >>>>>>> >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org>
AM
Adrian Mariano
Thu, Mar 14, 2024 7:08 PM

I use BOSL2's position() and align() much more than attach().  Take a look
at the Attachments tutorial
https://github.com/BelfrySCAD/BOSL2/wiki/Tutorial-Attachments

If you are not using position and align your code is probably a lot less
readable than it could be.  They mostly eliminate the need to use move /
translate and replace them with concepts like "put this object on the top
left of that one".  The attach() module also changes the object
orientation which I find is rarely what I need, and can be confusing, but
may be more useful in designs without right angles.

On Thu, Mar 14, 2024, 14:35 Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

I was actually responding to a comment Nop Head had made. No worries
though. Sounds like we have a similar background. My first programming job
was 1972.

-Bob

On Mar 12, 2024, at 18:47, John David ebo.2112@gmail.com wrote:

Bob, I am not sure what I wrote that you are objecting to (assuming the
objectionable comment is something I wrote).  I agree with most, if not
all, of what you have said.  I have yet to learn and use "attach".  I think
I am going to like it ;-)

With regards to readability and comments, I would also add using the
simplest standard features you can. Two of my funniest stories there are:

  • My first paid programming job was helping to write the OS for an
    embedded environmental monitor (circa 1979).  The company that commissioned
    the project was to cheap to purchase an assembled for it (which cost $6,000
    in 1975 dollars), so we hand assembled the code into HEX...  Skip forward
    maybe 5 years later, a friend who took over the project and built some of
    his own embedded projects surrounding the same RCA-1802 chip (which BTW is
    one of the same chips in the Hubble imager).  He was fighting with
    maintaining some code, and I bet him a case of Coca-Cola that I could write
    him a fully relocatable macro assembler for that architecture in 24 hours
    flat.  Well, I ran into a bug, and I blew through the 24hr mark, but I had
    it running by the 36hr mark.  He paid me the case of coke anyway, and used
    it for years... I wrote this in strict ANSI-compliant C, with a few dozen
    test-driven development sanity checks...  Skip forward to 1999 (pre-Y2K),
    and my buddy needed to fix a Y2K bug in a couple of the embedded machines.
    He called me up with some trepidation to bounce a few ideas off me.  He
    then recompiled the 15 year-old assembler, made the changes to the assembly
    code, ran it through and reinstalled the executables on the machines in a
    couple of hours.  He bought me another case of coke just to say thanks ;-)

  • the other story is about a PhD student I knew growing up, who developed
    a geometry compiler called G which was intended to provide low-level C-like
    geometric functionality similar to OpenSCAD primitives.  The heart of the
    compiler came down to about 6 lines of code that was so obfuscated, that I
    spent several months trying to wrap my head around them to fix a semantic
    bug and extend the functionality.  I gave up, but it was a readability
    lesson for me in my tender youth...

I am a strong proponent of eXtreme Programming (XP) and various literate
programming offshoots.  I really love how you can write your comments in
python and have the doc strings serve as hoverable documentation...

I'll go back and look at some of the shortcuts (like zrot, dire3ctions,
and attachment).

On Tue, Mar 12, 2024 at 7:33 PM Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

That comment is difficult to understand unless perhaps you have spent no
time looking at it.

First some basic facts.

  • Standard OS code still works in every instance I’m aware of.
  • the basic 2D and 3D shape modules still work but have added arguments
    that you need not use, but anchor is really useful.

The new translate and rotate modules up, down, left, right, fwd, and
back, xrot, yrot, and zrot. All are very intuitive and most of all,
readable. They are also more writable, with fewer keystrokes.

  • Up and down are translates on the Z axis. Up(a) I equivalent to
    translate([0, 0, a]). I think most will find "up" to be more readable.

  • Right and left move on the x-axis. When dealing with 2D it’ clear that
    positive x is right and negative x is left. Again, a lot more readable than
    translate([a, 0, 0]).

  • When you get to the Y axis, back must be +y and fwd, -y. This seems odd
    until you look ate the 3D rendering with the +X on the right. Then it makes
    perfect sense.

  • xrot, yrot and zrot are simply rotations around a single axis, xrot(a)
    is equivalent to rotate([a, 0, 0]). I find them way more readable and
    writable, extra punctuation and extra zeros.

  • I am better than average at visualization but I cannot visualize
    rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which
    is the equivalent.

  • What if you actually want xrot(a) yrot(b) zrot(c), which is different?
    The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]).
    Not easily readable.

Xcyl, ycyl and zcyl are just cylinders whose height is along the named
dimension.

  • Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0,
    90, 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise.

Attachability in BOSL2 is complicated  and I rarely use it. However,
anchors are the basis of attachability and I use them probably 95% of the
time I create a 2D or 3D shape.

  • an anchor is a place on the created shape
  • TOP and BOTTOM are you guessed it, the top and bottom of the shape.
    Likewise for LEFT, RIGHT, FRONT and BACK.
  • When you say cube([10, 20 30], anchor = TOP), the top center of the
    cube placed at the origin, [0, 0, 0].
  • These anchors are additive, so you can say cube([10, 20 30], anchor =
    TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y,
    -x) quadrant.
  • Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0,
    0, -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D
    vector form because it makes sense to me in the particular context.

Everything above I learned in about 10 minutes I think. It makes my code
much easier to read and faster to write. Probably 90% of my use of BOSL2 is
this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library.
I have no idea if the two libraries are compatible.

There is a lot of other stuff in BOSL2 that you can find when you need it
like shapes with chamfering and rounding and so on, but you can ignore it
until you need it.

I harp on readability here. Decades ago I settled on that as the priority
when I write code. You write it once but you read it many times. I was
reminded of this recently. When I got my first 3D printer about 3 years ago
I put aside an IOS app I was working in Xcode and Swift. I recently pulled
it out and began working on it again. Boy did that remind me how important
readability and comments are.

-Bob

On Mar 11, 2024, at 17:07, nop head via Discuss <
discuss@lists.openscad.org> wrote:

It is the opposite for me. I can understand basic OpenSCAD code with
translates and rotates but I can't understand any BOSL2 code. I would have
to learn a new language.

On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

BOSL2 may have lots of stuff that is unneeded the vast majority of the
time. However, the basics of BOSL2 have become essential to my use of
OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot,
xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK,
make your code so much more readable that I think it is a huge mistake to
not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would
be incorporated into the base product.

-Bob

On Mar 11, 2024, at 15:35, John David via Discuss <
discuss@lists.openscad.org> wrote:

Thank you, Ray,

I have seen a couple of the videos that "A Glimpse Inside" guy does, and
as I start building my toolholders I will likely go back and watch them
again in the future for ideas.  You are right.  Using BOSL2, or any of this
advanced stuff, is gross overkill.  I had already used OpenSCAD to model a
conventional solid cleat, as well as the simpler thin-cleats like in the
video.  I spent way too much time learning OpenSCAD syntax and semantics,
building my first couple of toolholders as OpenSCAD assemblies using simple
cube, triangle, calendar, union, difference...  (I hope I am using the
correct terminology).  Anyway, when I started thinking of making
toolholders out of tabbed-boxes is what send me down the current bunny
trail.  I am really only working on this late at night as I am starting to
wind down before I go to bed...  My current status is that I build the
profiles (in 2D), and then can add to them, extrude them, etc.  At this
point, I can parametrically generate the simplest of the thin cleats, with
a foot/standoff, a top(not sure what to best name it), side width, etc.
designs

The next step will be to take one or two of my toolholder designs and
make one or more.  My first modeled toolholder, which I have not made yet,
is for a lasercut Kobalt 24v charging station.  A charger is vertically
mounted on the top, there is room for 4 full sized batteries to slide and
lock into place, an open space in the back for the power cord, and the
bottom is flat so it can be carried around and set down on a work table.  I
even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a
small finishing nail to act as alignment pin.  With any luck, that will
work, but it is a good learning exercise.  The one thing I have not figured
out yet is how to modify the cleat so that it also functions as an
erstwhile handle.

Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still
learning the OpenSCAD syntax and I came across heatmap before I came across
advanced associative arrays and structs.

Thanks all for the suggesting and feedback.

On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

Hashmap may be overkill here. Why not use structs instead?  I think
they have some error checking features you won’t get with hashmap to
prevent creation of incorrect fields.

On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

On 3/10/2024 6:00 PM, John David wrote:

OK.  It is starting to take shape.  What I did was to build a named
parameter list that looks like:

 [["cleat","type",type],
  ["cleat","thickness",thickness],
  ["cleat","width",width],
  ["cleat","chamfer",chamfer],
  ["cleat","kerf",kerf],
  ["cleat","angle",angle],
  ["cleat","profile",_fc_cleat_profile

(width,thickness,chamfer,angle,kerf)]];

That can work.  One of these days we'll get PR#4478 in and we'll have
a more concise syntax for this kind of thing.

I am confused about the warnings that are being generated by the
search.  Anyone have suggestions on how to fix those?

Older versions gave warnings when search() did not find a match.
Current development snapshots do not.

[...] I like some of the [BOSL2] functionality with the hashmap
(specifically del and additems).

Note that those functions do not modify existing hashmaps; they create
new hashmaps with the changes requested.  Again, OpenSCAD variables are
immutable, and that includes arrays.


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


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


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


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

I use BOSL2's position() and align() much more than attach(). Take a look at the Attachments tutorial https://github.com/BelfrySCAD/BOSL2/wiki/Tutorial-Attachments If you are not using position and align your code is probably a lot less readable than it could be. They mostly eliminate the need to use move / translate and replace them with concepts like "put this object on the top left of that one". The attach() module also changes the object orientation which I find is rarely what I need, and can be confusing, but may be more useful in designs without right angles. On Thu, Mar 14, 2024, 14:35 Bob Carlson via Discuss < discuss@lists.openscad.org> wrote: > I was actually responding to a comment Nop Head had made. No worries > though. Sounds like we have a similar background. My first programming job > was 1972. > > -Bob > > On Mar 12, 2024, at 18:47, John David <ebo.2112@gmail.com> wrote: > > Bob, I am not sure what I wrote that you are objecting to (assuming the > objectionable comment is something I wrote). I agree with most, if not > all, of what you have said. I have yet to learn and use "attach". I think > I am going to like it ;-) > > With regards to readability and comments, I would also add using the > simplest standard features you can. Two of my funniest stories there are: > > * My first paid programming job was helping to write the OS for an > embedded environmental monitor (circa 1979). The company that commissioned > the project was to cheap to purchase an assembled for it (which cost $6,000 > in 1975 dollars), so we hand assembled the code into HEX... Skip forward > maybe 5 years later, a friend who took over the project and built some of > his own embedded projects surrounding the same RCA-1802 chip (which BTW is > one of the same chips in the Hubble imager). He was fighting with > maintaining some code, and I bet him a case of Coca-Cola that I could write > him a fully relocatable macro assembler for that architecture in 24 hours > flat. Well, I ran into a bug, and I blew through the 24hr mark, but I had > it running by the 36hr mark. He paid me the case of coke anyway, and used > it for years... I wrote this in strict ANSI-compliant C, with a few dozen > test-driven development sanity checks... Skip forward to 1999 (pre-Y2K), > and my buddy needed to fix a Y2K bug in a couple of the embedded machines. > He called me up with some trepidation to bounce a few ideas off me. He > then recompiled the 15 year-old assembler, made the changes to the assembly > code, ran it through and reinstalled the executables on the machines in a > couple of hours. He bought me another case of coke just to say thanks ;-) > > * the other story is about a PhD student I knew growing up, who developed > a geometry compiler called G which was intended to provide low-level C-like > geometric functionality similar to OpenSCAD primitives. The heart of the > compiler came down to about 6 lines of code that was so obfuscated, that I > spent several months trying to wrap my head around them to fix a semantic > bug and extend the functionality. I gave up, but it was a readability > lesson for me in my tender youth... > > I am a strong proponent of eXtreme Programming (XP) and various literate > programming offshoots. I really love how you can write your comments in > python and have the doc strings serve as hoverable documentation... > > I'll go back and look at some of the shortcuts (like zrot, dire3ctions, > and attachment). > > > > On Tue, Mar 12, 2024 at 7:33 PM Bob Carlson via Discuss < > discuss@lists.openscad.org> wrote: > >> That comment is difficult to understand unless perhaps you have spent no >> time looking at it. >> >> First some basic facts. >> - Standard OS code still works in every instance I’m aware of. >> - the basic 2D and 3D shape modules still work but have added arguments >> that you need not use, but anchor is really useful. >> >> The new translate and rotate modules up, down, left, right, fwd, and >> back, xrot, yrot, and zrot. All are very intuitive and most of all, >> readable. They are also more writable, with fewer keystrokes. >> - Up and down are translates on the Z axis. Up(a) I equivalent to >> translate([0, 0, a]). I think most will find "up" to be more readable. >> - Right and left move on the x-axis. When dealing with 2D it’ clear that >> positive x is right and negative x is left. Again, a lot more readable than >> translate([a, 0, 0]). >> - When you get to the Y axis, back must be +y and fwd, -y. This seems odd >> until you look ate the 3D rendering with the +X on the right. Then it makes >> perfect sense. >> >> - xrot, yrot and zrot are simply rotations around a single axis, xrot(a) >> is equivalent to rotate([a, 0, 0]). I find them way more readable and >> writable, extra punctuation and extra zeros. >> - I am better than average at visualization but I cannot visualize >> rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which >> is the equivalent. >> - What if you actually want xrot(a) yrot(b) zrot(c), which is different? >> The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]). >> Not easily readable. >> >> Xcyl, ycyl and zcyl are just cylinders whose height is along the named >> dimension. >> - Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0, >> 90, 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise. >> >> Attachability in BOSL2 is complicated and I rarely use it. However, >> anchors are the basis of attachability and I use them probably 95% of the >> time I create a 2D or 3D shape. >> - an anchor is a place on the created shape >> - TOP and BOTTOM are you guessed it, the top and bottom of the shape. >> Likewise for LEFT, RIGHT, FRONT and BACK. >> - When you say cube([10, 20 30], anchor = TOP), the top center of the >> cube placed at the origin, [0, 0, 0]. >> - These anchors are additive, so you can say cube([10, 20 30], anchor = >> TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y, >> -x) quadrant. >> - Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0, >> 0, -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D >> vector form because it makes sense to me in the particular context. >> >> Everything above I learned in about 10 minutes I think. It makes my code >> much easier to read and faster to write. Probably 90% of my use of BOSL2 is >> this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library. >> I have no idea if the two libraries are compatible. >> >> There is a lot of other stuff in BOSL2 that you can find when you need it >> like shapes with chamfering and rounding and so on, but you can ignore it >> until you need it. >> >> I harp on readability here. Decades ago I settled on that as the priority >> when I write code. You write it once but you read it many times. I was >> reminded of this recently. When I got my first 3D printer about 3 years ago >> I put aside an IOS app I was working in Xcode and Swift. I recently pulled >> it out and began working on it again. Boy did that remind me how important >> readability and comments are. >> >> -Bob >> >> >> On Mar 11, 2024, at 17:07, nop head via Discuss < >> discuss@lists.openscad.org> wrote: >> >> It is the opposite for me. I can understand basic OpenSCAD code with >> translates and rotates but I can't understand any BOSL2 code. I would have >> to learn a new language. >> >> On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> BOSL2 may have lots of stuff that is unneeded the vast majority of the >>> time. However, the basics of BOSL2 have become essential to my use of >>> OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot, >>> xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK, >>> make your code so much more readable that I think it is a huge mistake to >>> not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would >>> be incorporated into the base product. >>> >>> -Bob >>> >>> On Mar 11, 2024, at 15:35, John David via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>> Thank you, Ray, >>> >>> I have seen a couple of the videos that "A Glimpse Inside" guy does, and >>> as I start building my toolholders I will likely go back and watch them >>> again in the future for ideas. You are right. Using BOSL2, or any of this >>> advanced stuff, is gross overkill. I had already used OpenSCAD to model a >>> conventional solid cleat, as well as the simpler thin-cleats like in the >>> video. I spent *way* too much time learning OpenSCAD syntax and semantics, >>> building my first couple of toolholders as OpenSCAD assemblies using simple >>> cube, triangle, calendar, union, difference... (I hope I am using the >>> correct terminology). Anyway, when I started thinking of making >>> toolholders out of tabbed-boxes is what send me down the current bunny >>> trail. I am really only working on this late at night as I am starting to >>> wind down before I go to bed... My current status is that I build the >>> profiles (in 2D), and then can add to them, extrude them, etc. At this >>> point, I can parametrically generate the simplest of the thin cleats, with >>> a foot/standoff, a top(not sure what to best name it), side width, etc. >>> designs >>> >>> The next step will be to take one or two of my toolholder designs and >>> make one or more. My first modeled toolholder, which I have not made yet, >>> is for a lasercut Kobalt 24v charging station. A charger is vertically >>> mounted on the top, there is room for 4 full sized batteries to slide and >>> lock into place, an open space in the back for the power cord, and the >>> bottom is flat so it can be carried around and set down on a work table. I >>> even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a >>> small finishing nail to act as alignment pin. With any luck, that will >>> work, but it is a good learning exercise. The one thing I have not figured >>> out yet is how to modify the cleat so that it also functions as an >>> erstwhile handle. >>> >>> Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still >>> learning the OpenSCAD syntax and I came across heatmap before I came across >>> advanced associative arrays and structs. >>> >>> Thanks all for the suggesting and feedback. >>> >>> On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> Hashmap may be overkill here. Why not use structs instead? I think >>>> they have some error checking features you won’t get with hashmap to >>>> prevent creation of incorrect fields. >>>> >>>> On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>>> On 3/10/2024 6:00 PM, John David wrote: >>>>> >>>>> OK. It is starting to take shape. What I did was to build a named >>>>> parameter list that looks like: >>>>> >>>>> [["cleat","type",type], >>>>> ["cleat","thickness",thickness], >>>>> ["cleat","width",width], >>>>> ["cleat","chamfer",chamfer], >>>>> ["cleat","kerf",kerf], >>>>> ["cleat","angle",angle], >>>>> ["cleat","profile",_fc_cleat_profile >>>>> (width,thickness,chamfer,angle,kerf)]]; >>>>> >>>>> >>>>> That can work. One of these days we'll get PR#4478 in and we'll have >>>>> a more concise syntax for this kind of thing. >>>>> >>>>> I am confused about the warnings that are being generated by the >>>>> search. Anyone have suggestions on how to fix those? >>>>> >>>>> >>>>> Older versions gave warnings when search() did not find a match. >>>>> Current development snapshots do not. >>>>> >>>>> [...] I like some of the [BOSL2] functionality with the hashmap >>>>> (specifically del and additems). >>>>> >>>>> >>>>> Note that those functions do not modify existing hashmaps; they create >>>>> new hashmaps with the changes requested. Again, OpenSCAD variables are >>>>> immutable, and that includes arrays. >>>>> >>>>> _______________________________________________ >>>>> 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 >>>> >>> _______________________________________________ >>> 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 >>> >> _______________________________________________ >> 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 >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JD
John David
Thu, Mar 14, 2024 10:15 PM

Thank you, Adrian, for the link and the advice.  Is the use of align and
position sufficiently covered in the attachment tutorial, or should I look
elsewhere in addition?

Seriously, thanks for the pointers on the attachment tutorial.

EBo --

On Thu, Mar 14, 2024 at 3:09 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

I use BOSL2's position() and align() much more than attach().  Take a look
at the Attachments tutorial
https://github.com/BelfrySCAD/BOSL2/wiki/Tutorial-Attachments

If you are not using position and align your code is probably a lot less
readable than it could be.  They mostly eliminate the need to use move /
translate and replace them with concepts like "put this object on the top
left of that one".  The attach() module also changes the object
orientation which I find is rarely what I need, and can be confusing, but
may be more useful in designs without right angles.

On Thu, Mar 14, 2024, 14:35 Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

I was actually responding to a comment Nop Head had made. No worries
though. Sounds like we have a similar background. My first programming job
was 1972.

-Bob

On Mar 12, 2024, at 18:47, John David ebo.2112@gmail.com wrote:

Bob, I am not sure what I wrote that you are objecting to (assuming the
objectionable comment is something I wrote).  I agree with most, if not
all, of what you have said.  I have yet to learn and use "attach".  I think
I am going to like it ;-)

With regards to readability and comments, I would also add using the
simplest standard features you can. Two of my funniest stories there are:

  • My first paid programming job was helping to write the OS for an
    embedded environmental monitor (circa 1979).  The company that commissioned
    the project was to cheap to purchase an assembled for it (which cost $6,000
    in 1975 dollars), so we hand assembled the code into HEX...  Skip forward
    maybe 5 years later, a friend who took over the project and built some of
    his own embedded projects surrounding the same RCA-1802 chip (which BTW is
    one of the same chips in the Hubble imager).  He was fighting with
    maintaining some code, and I bet him a case of Coca-Cola that I could write
    him a fully relocatable macro assembler for that architecture in 24 hours
    flat.  Well, I ran into a bug, and I blew through the 24hr mark, but I had
    it running by the 36hr mark.  He paid me the case of coke anyway, and used
    it for years... I wrote this in strict ANSI-compliant C, with a few dozen
    test-driven development sanity checks...  Skip forward to 1999 (pre-Y2K),
    and my buddy needed to fix a Y2K bug in a couple of the embedded machines.
    He called me up with some trepidation to bounce a few ideas off me.  He
    then recompiled the 15 year-old assembler, made the changes to the assembly
    code, ran it through and reinstalled the executables on the machines in a
    couple of hours.  He bought me another case of coke just to say thanks ;-)

  • the other story is about a PhD student I knew growing up, who developed
    a geometry compiler called G which was intended to provide low-level C-like
    geometric functionality similar to OpenSCAD primitives.  The heart of the
    compiler came down to about 6 lines of code that was so obfuscated, that I
    spent several months trying to wrap my head around them to fix a semantic
    bug and extend the functionality.  I gave up, but it was a readability
    lesson for me in my tender youth...

I am a strong proponent of eXtreme Programming (XP) and various literate
programming offshoots.  I really love how you can write your comments in
python and have the doc strings serve as hoverable documentation...

I'll go back and look at some of the shortcuts (like zrot, dire3ctions,
and attachment).

On Tue, Mar 12, 2024 at 7:33 PM Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

That comment is difficult to understand unless perhaps you have spent no
time looking at it.

First some basic facts.

  • Standard OS code still works in every instance I’m aware of.
  • the basic 2D and 3D shape modules still work but have added arguments
    that you need not use, but anchor is really useful.

The new translate and rotate modules up, down, left, right, fwd, and
back, xrot, yrot, and zrot. All are very intuitive and most of all,
readable. They are also more writable, with fewer keystrokes.

  • Up and down are translates on the Z axis. Up(a) I equivalent to
    translate([0, 0, a]). I think most will find "up" to be more readable.

  • Right and left move on the x-axis. When dealing with 2D it’ clear that
    positive x is right and negative x is left. Again, a lot more readable than
    translate([a, 0, 0]).

  • When you get to the Y axis, back must be +y and fwd, -y. This seems
    odd until you look ate the 3D rendering with the +X on the right. Then it
    makes perfect sense.

  • xrot, yrot and zrot are simply rotations around a single axis, xrot(a)
    is equivalent to rotate([a, 0, 0]). I find them way more readable and
    writable, extra punctuation and extra zeros.

  • I am better than average at visualization but I cannot visualize
    rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which
    is the equivalent.

  • What if you actually want xrot(a) yrot(b) zrot(c), which is different?
    The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]).
    Not easily readable.

Xcyl, ycyl and zcyl are just cylinders whose height is along the named
dimension.

  • Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0,
    90, 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise.

Attachability in BOSL2 is complicated  and I rarely use it. However,
anchors are the basis of attachability and I use them probably 95% of the
time I create a 2D or 3D shape.

  • an anchor is a place on the created shape
  • TOP and BOTTOM are you guessed it, the top and bottom of the shape.
    Likewise for LEFT, RIGHT, FRONT and BACK.
  • When you say cube([10, 20 30], anchor = TOP), the top center of the
    cube placed at the origin, [0, 0, 0].
  • These anchors are additive, so you can say cube([10, 20 30], anchor =
    TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y,
    -x) quadrant.
  • Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0,
    0, -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D
    vector form because it makes sense to me in the particular context.

Everything above I learned in about 10 minutes I think. It makes my code
much easier to read and faster to write. Probably 90% of my use of BOSL2 is
this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library.
I have no idea if the two libraries are compatible.

There is a lot of other stuff in BOSL2 that you can find when you need
it like shapes with chamfering and rounding and so on, but you can ignore
it until you need it.

I harp on readability here. Decades ago I settled on that as the
priority when I write code. You write it once but you read it many times. I
was reminded of this recently. When I got my first 3D printer about 3 years
ago I put aside an IOS app I was working in Xcode and Swift. I recently
pulled it out and began working on it again. Boy did that remind me how
important readability and comments are.

-Bob

On Mar 11, 2024, at 17:07, nop head via Discuss <
discuss@lists.openscad.org> wrote:

It is the opposite for me. I can understand basic OpenSCAD code with
translates and rotates but I can't understand any BOSL2 code. I would have
to learn a new language.

On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss <
discuss@lists.openscad.org> wrote:

BOSL2 may have lots of stuff that is unneeded the vast majority of the
time. However, the basics of BOSL2 have become essential to my use of
OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot,
xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK,
make your code so much more readable that I think it is a huge mistake to
not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would
be incorporated into the base product.

-Bob

On Mar 11, 2024, at 15:35, John David via Discuss <
discuss@lists.openscad.org> wrote:

Thank you, Ray,

I have seen a couple of the videos that "A Glimpse Inside" guy does,
and as I start building my toolholders I will likely go back and watch them
again in the future for ideas.  You are right.  Using BOSL2, or any of this
advanced stuff, is gross overkill.  I had already used OpenSCAD to model a
conventional solid cleat, as well as the simpler thin-cleats like in the
video.  I spent way too much time learning OpenSCAD syntax and semantics,
building my first couple of toolholders as OpenSCAD assemblies using simple
cube, triangle, calendar, union, difference...  (I hope I am using the
correct terminology).  Anyway, when I started thinking of making
toolholders out of tabbed-boxes is what send me down the current bunny
trail.  I am really only working on this late at night as I am starting to
wind down before I go to bed...  My current status is that I build the
profiles (in 2D), and then can add to them, extrude them, etc.  At this
point, I can parametrically generate the simplest of the thin cleats, with
a foot/standoff, a top(not sure what to best name it), side width, etc.
designs

The next step will be to take one or two of my toolholder designs and
make one or more.  My first modeled toolholder, which I have not made yet,
is for a lasercut Kobalt 24v charging station.  A charger is vertically
mounted on the top, there is room for 4 full sized batteries to slide and
lock into place, an open space in the back for the power cord, and the
bottom is flat so it can be carried around and set down on a work table.  I
even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a
small finishing nail to act as alignment pin.  With any luck, that will
work, but it is a good learning exercise.  The one thing I have not figured
out yet is how to modify the cleat so that it also functions as an
erstwhile handle.

Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still
learning the OpenSCAD syntax and I came across heatmap before I came across
advanced associative arrays and structs.

Thanks all for the suggesting and feedback.

On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:

Hashmap may be overkill here. Why not use structs instead?  I think
they have some error checking features you won’t get with hashmap to
prevent creation of incorrect fields.

On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

On 3/10/2024 6:00 PM, John David wrote:

OK.  It is starting to take shape.  What I did was to build a named
parameter list that looks like:

 [["cleat","type",type],
  ["cleat","thickness",thickness],
  ["cleat","width",width],
  ["cleat","chamfer",chamfer],
  ["cleat","kerf",kerf],
  ["cleat","angle",angle],
  ["cleat","profile",_fc_cleat_profile

(width,thickness,chamfer,angle,kerf)]];

That can work.  One of these days we'll get PR#4478 in and we'll have
a more concise syntax for this kind of thing.

I am confused about the warnings that are being generated by the
search.  Anyone have suggestions on how to fix those?

Older versions gave warnings when search() did not find a match.
Current development snapshots do not.

[...] I like some of the [BOSL2] functionality with the hashmap
(specifically del and additems).

Note that those functions do not modify existing hashmaps; they
create new hashmaps with the changes requested.  Again, OpenSCAD variables
are immutable, and that includes arrays.


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


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


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


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

Thank you, Adrian, for the link and the advice. Is the use of align and position sufficiently covered in the attachment tutorial, or should I look elsewhere in addition? Seriously, thanks for the pointers on the attachment tutorial. EBo -- On Thu, Mar 14, 2024 at 3:09 PM Adrian Mariano via Discuss < discuss@lists.openscad.org> wrote: > I use BOSL2's position() and align() much more than attach(). Take a look > at the Attachments tutorial > https://github.com/BelfrySCAD/BOSL2/wiki/Tutorial-Attachments > > If you are not using position and align your code is probably a lot less > readable than it could be. They mostly eliminate the need to use move / > translate and replace them with concepts like "put this object on the top > left of that one". The attach() module also changes the object > orientation which I find is rarely what I need, and can be confusing, but > may be more useful in designs without right angles. > > On Thu, Mar 14, 2024, 14:35 Bob Carlson via Discuss < > discuss@lists.openscad.org> wrote: > >> I was actually responding to a comment Nop Head had made. No worries >> though. Sounds like we have a similar background. My first programming job >> was 1972. >> >> -Bob >> >> On Mar 12, 2024, at 18:47, John David <ebo.2112@gmail.com> wrote: >> >> Bob, I am not sure what I wrote that you are objecting to (assuming the >> objectionable comment is something I wrote). I agree with most, if not >> all, of what you have said. I have yet to learn and use "attach". I think >> I am going to like it ;-) >> >> With regards to readability and comments, I would also add using the >> simplest standard features you can. Two of my funniest stories there are: >> >> * My first paid programming job was helping to write the OS for an >> embedded environmental monitor (circa 1979). The company that commissioned >> the project was to cheap to purchase an assembled for it (which cost $6,000 >> in 1975 dollars), so we hand assembled the code into HEX... Skip forward >> maybe 5 years later, a friend who took over the project and built some of >> his own embedded projects surrounding the same RCA-1802 chip (which BTW is >> one of the same chips in the Hubble imager). He was fighting with >> maintaining some code, and I bet him a case of Coca-Cola that I could write >> him a fully relocatable macro assembler for that architecture in 24 hours >> flat. Well, I ran into a bug, and I blew through the 24hr mark, but I had >> it running by the 36hr mark. He paid me the case of coke anyway, and used >> it for years... I wrote this in strict ANSI-compliant C, with a few dozen >> test-driven development sanity checks... Skip forward to 1999 (pre-Y2K), >> and my buddy needed to fix a Y2K bug in a couple of the embedded machines. >> He called me up with some trepidation to bounce a few ideas off me. He >> then recompiled the 15 year-old assembler, made the changes to the assembly >> code, ran it through and reinstalled the executables on the machines in a >> couple of hours. He bought me another case of coke just to say thanks ;-) >> >> * the other story is about a PhD student I knew growing up, who developed >> a geometry compiler called G which was intended to provide low-level C-like >> geometric functionality similar to OpenSCAD primitives. The heart of the >> compiler came down to about 6 lines of code that was so obfuscated, that I >> spent several months trying to wrap my head around them to fix a semantic >> bug and extend the functionality. I gave up, but it was a readability >> lesson for me in my tender youth... >> >> I am a strong proponent of eXtreme Programming (XP) and various literate >> programming offshoots. I really love how you can write your comments in >> python and have the doc strings serve as hoverable documentation... >> >> I'll go back and look at some of the shortcuts (like zrot, dire3ctions, >> and attachment). >> >> >> >> On Tue, Mar 12, 2024 at 7:33 PM Bob Carlson via Discuss < >> discuss@lists.openscad.org> wrote: >> >>> That comment is difficult to understand unless perhaps you have spent no >>> time looking at it. >>> >>> First some basic facts. >>> - Standard OS code still works in every instance I’m aware of. >>> - the basic 2D and 3D shape modules still work but have added arguments >>> that you need not use, but anchor is really useful. >>> >>> The new translate and rotate modules up, down, left, right, fwd, and >>> back, xrot, yrot, and zrot. All are very intuitive and most of all, >>> readable. They are also more writable, with fewer keystrokes. >>> - Up and down are translates on the Z axis. Up(a) I equivalent to >>> translate([0, 0, a]). I think most will find "up" to be more readable. >>> - Right and left move on the x-axis. When dealing with 2D it’ clear that >>> positive x is right and negative x is left. Again, a lot more readable than >>> translate([a, 0, 0]). >>> - When you get to the Y axis, back must be +y and fwd, -y. This seems >>> odd until you look ate the 3D rendering with the +X on the right. Then it >>> makes perfect sense. >>> >>> - xrot, yrot and zrot are simply rotations around a single axis, xrot(a) >>> is equivalent to rotate([a, 0, 0]). I find them way more readable and >>> writable, extra punctuation and extra zeros. >>> - I am better than average at visualization but I cannot visualize >>> rotate([a, b, c]). I can however, visualize zrot(c) yrot(b) xrot(a), which >>> is the equivalent. >>> - What if you actually want xrot(a) yrot(b) zrot(c), which is different? >>> The equivalent is rotate([0, 0, c]) rotate([0, b, 0]) rotate([a, 0, 0]). >>> Not easily readable. >>> >>> Xcyl, ycyl and zcyl are just cylinders whose height is along the named >>> dimension. >>> - Zcyl is equivalent to cylinder, but xcyl is equivalent to rotate([0, >>> 90, 0]) cylinder(). Way easier to read or write. Ycyl left as an exercise. >>> >>> Attachability in BOSL2 is complicated and I rarely use it. However, >>> anchors are the basis of attachability and I use them probably 95% of the >>> time I create a 2D or 3D shape. >>> - an anchor is a place on the created shape >>> - TOP and BOTTOM are you guessed it, the top and bottom of the shape. >>> Likewise for LEFT, RIGHT, FRONT and BACK. >>> - When you say cube([10, 20 30], anchor = TOP), the top center of the >>> cube placed at the origin, [0, 0, 0]. >>> - These anchors are additive, so you can say cube([10, 20 30], anchor = >>> TOP + RIGHT + BACK). This produces a cube in lower, front, left (-z, -y, >>> -x) quadrant. >>> - Adding works smoothly because TOP = [0, 0, 1] and BOTTOM or BOT = [0, >>> 0, -1]. RIGHT = [1, 0, 0] and so on. On rare occasions I’ll use the 3D >>> vector form because it makes sense to me in the particular context. >>> >>> Everything above I learned in about 10 minutes I think. It makes my code >>> much easier to read and faster to write. Probably 90% of my use of BOSL2 is >>> this stuff. Much of the rest of BOSL2 probably overlaps Nop Head’s library. >>> I have no idea if the two libraries are compatible. >>> >>> There is a lot of other stuff in BOSL2 that you can find when you need >>> it like shapes with chamfering and rounding and so on, but you can ignore >>> it until you need it. >>> >>> I harp on readability here. Decades ago I settled on that as the >>> priority when I write code. You write it once but you read it many times. I >>> was reminded of this recently. When I got my first 3D printer about 3 years >>> ago I put aside an IOS app I was working in Xcode and Swift. I recently >>> pulled it out and began working on it again. Boy did that remind me how >>> important readability and comments are. >>> >>> -Bob >>> >>> >>> On Mar 11, 2024, at 17:07, nop head via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>> It is the opposite for me. I can understand basic OpenSCAD code with >>> translates and rotates but I can't understand any BOSL2 code. I would have >>> to learn a new language. >>> >>> On Mon, 11 Mar 2024 at 23:18, Bob Carlson via Discuss < >>> discuss@lists.openscad.org> wrote: >>> >>>> BOSL2 may have lots of stuff that is unneeded the vast majority of the >>>> time. However, the basics of BOSL2 have become essential to my use of >>>> OpenSCAD. Using up, down, left, right, fwd, and back, xrot, yrot, and zrot, >>>> xcyl, ycyl and zcyl, the anchors RIGHT, LEFT, TOP, BOT, FRONT and BACK, >>>> make your code so much more readable that I think it is a huge mistake to >>>> not use BOSL2. I do nothing without it in OpenSCAD. If I were king it would >>>> be incorporated into the base product. >>>> >>>> -Bob >>>> >>>> On Mar 11, 2024, at 15:35, John David via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>> Thank you, Ray, >>>> >>>> I have seen a couple of the videos that "A Glimpse Inside" guy does, >>>> and as I start building my toolholders I will likely go back and watch them >>>> again in the future for ideas. You are right. Using BOSL2, or any of this >>>> advanced stuff, is gross overkill. I had already used OpenSCAD to model a >>>> conventional solid cleat, as well as the simpler thin-cleats like in the >>>> video. I spent *way* too much time learning OpenSCAD syntax and semantics, >>>> building my first couple of toolholders as OpenSCAD assemblies using simple >>>> cube, triangle, calendar, union, difference... (I hope I am using the >>>> correct terminology). Anyway, when I started thinking of making >>>> toolholders out of tabbed-boxes is what send me down the current bunny >>>> trail. I am really only working on this late at night as I am starting to >>>> wind down before I go to bed... My current status is that I build the >>>> profiles (in 2D), and then can add to them, extrude them, etc. At this >>>> point, I can parametrically generate the simplest of the thin cleats, with >>>> a foot/standoff, a top(not sure what to best name it), side width, etc. >>>> designs >>>> >>>> The next step will be to take one or two of my toolholder designs and >>>> make one or more. My first modeled toolholder, which I have not made yet, >>>> is for a lasercut Kobalt 24v charging station. A charger is vertically >>>> mounted on the top, there is room for 4 full sized batteries to slide and >>>> lock into place, an open space in the back for the power cord, and the >>>> bottom is flat so it can be carried around and set down on a work table. I >>>> even modeled the locking clip as a sandwiched 1/4" plywood cutouts with a >>>> small finishing nail to act as alignment pin. With any luck, that will >>>> work, but it is a good learning exercise. The one thing I have not figured >>>> out yet is how to modify the cleat so that it also functions as an >>>> erstwhile handle. >>>> >>>> Adrian, I agree -- hashmap is WAY overkill, but to be frank, I am still >>>> learning the OpenSCAD syntax and I came across heatmap before I came across >>>> advanced associative arrays and structs. >>>> >>>> Thanks all for the suggesting and feedback. >>>> >>>> On Mon, Mar 11, 2024 at 12:09 PM Adrian Mariano via Discuss < >>>> discuss@lists.openscad.org> wrote: >>>> >>>>> Hashmap may be overkill here. Why not use structs instead? I think >>>>> they have some error checking features you won’t get with hashmap to >>>>> prevent creation of incorrect fields. >>>>> >>>>> On Mon, Mar 11, 2024 at 12:03 Jordan Brown via Discuss < >>>>> discuss@lists.openscad.org> wrote: >>>>> >>>>>> On 3/10/2024 6:00 PM, John David wrote: >>>>>> >>>>>> OK. It is starting to take shape. What I did was to build a named >>>>>> parameter list that looks like: >>>>>> >>>>>> [["cleat","type",type], >>>>>> ["cleat","thickness",thickness], >>>>>> ["cleat","width",width], >>>>>> ["cleat","chamfer",chamfer], >>>>>> ["cleat","kerf",kerf], >>>>>> ["cleat","angle",angle], >>>>>> ["cleat","profile",_fc_cleat_profile >>>>>> (width,thickness,chamfer,angle,kerf)]]; >>>>>> >>>>>> >>>>>> That can work. One of these days we'll get PR#4478 in and we'll have >>>>>> a more concise syntax for this kind of thing. >>>>>> >>>>>> I am confused about the warnings that are being generated by the >>>>>> search. Anyone have suggestions on how to fix those? >>>>>> >>>>>> >>>>>> Older versions gave warnings when search() did not find a match. >>>>>> Current development snapshots do not. >>>>>> >>>>>> [...] I like some of the [BOSL2] functionality with the hashmap >>>>>> (specifically del and additems). >>>>>> >>>>>> >>>>>> Note that those functions do not modify existing hashmaps; they >>>>>> create new hashmaps with the changes requested. Again, OpenSCAD variables >>>>>> are immutable, and that includes arrays. >>>>>> >>>>>> _______________________________________________ >>>>>> 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 >>>>> >>>> _______________________________________________ >>>> 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 >>>> >>> _______________________________________________ >>> 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 >>> >> >> _______________________________________________ >> 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 >