RV
Roel Vanhout
Fri, May 9, 2025 9:04 AM
Hello all,
A long time ago, I got the code below from someone on this list to
facilitate having multiple parts in a .scad file and easily switch between
them / have them laid out with spacing in between / export them as separate
parts. Basically you use it like this:
$content_selected = "part1"; // "all" for all parts
contents() {
item("part1") part1();
item("part2") part2();
}
and this will only show the module part1. Now what I would like to do is
add the option for $content_selected to (optionally) be an array and select
multiple parts to be shown at once, without showing all. What I'm running
into is that I would need some way to access a "property" of children(i) in
the code below that has that item()'s value that was passed in as the
"name" parameter. I don't think there is a way for modules to export their
internal parameters though, so I'm wondering if anyone has an idea on how
to work around this, or some other approach to solving this problem. Thanks.
regards
Roel
module contents(d = 120) {
nx = ceil(sqrt($children));
ny = ceil($children/nx);
for (xi=[0:nx-1], yi=[0:ny-1]) {
i = xi + yi * nx;
if (i < $children) {
if (is_undef($content_selected) || $content_selected == "all") {
translate([xi * d, yi * d, 0]) children(i);
} else {
children(i);
}
}
}
}
module item(name, png = true, stl = true, distance, xrot, zrot, z) {
if (is_undef($content_inventory)) {
if (is_undef($content_selected) || $content_selected == "all" ||
$content_selected == name) {
echo(str("Exporting ", name));
children();
}
} else {
_distance = default(distance, 150);
_zrot = default(zrot, 30);
_xrot = default(xrot, 60);
_z = default(z, 15);
camera = is_undef(distance) && is_undef(zrot) && is_undef(z) &&
is_undef(xrot)
? "--viewall"
: str("--camera 0,0,", _z, ",", _xrot, ",0,", _zrot, ",",
_distance);
if ($content_inventory == "all")
echo("PART", name);
else if ($content_inventory == "png" && png)
echo("PART", name, camera);
else if ($content_inventory == "stl" && stl)
echo("PART", name);
}
}
Hello all,
A long time ago, I got the code below from someone on this list to
facilitate having multiple parts in a .scad file and easily switch between
them / have them laid out with spacing in between / export them as separate
parts. Basically you use it like this:
$content_selected = "part1"; // "all" for all parts
contents() {
item("part1") part1();
item("part2") part2();
}
and this will only show the module part1. Now what I would like to do is
add the option for $content_selected to (optionally) be an array and select
multiple parts to be shown at once, without showing all. What I'm running
into is that I would need some way to access a "property" of children(i) in
the code below that has that item()'s value that was passed in as the
"name" parameter. I don't think there is a way for modules to export their
internal parameters though, so I'm wondering if anyone has an idea on how
to work around this, or some other approach to solving this problem. Thanks.
regards
Roel
module contents(d = 120) {
nx = ceil(sqrt($children));
ny = ceil($children/nx);
for (xi=[0:nx-1], yi=[0:ny-1]) {
i = xi + yi * nx;
if (i < $children) {
if (is_undef($content_selected) || $content_selected == "all") {
translate([xi * d, yi * d, 0]) children(i);
} else {
children(i);
}
}
}
}
module item(name, png = true, stl = true, distance, xrot, zrot, z) {
if (is_undef($content_inventory)) {
if (is_undef($content_selected) || $content_selected == "all" ||
$content_selected == name) {
echo(str("Exporting ", name));
children();
}
} else {
_distance = default(distance, 150);
_zrot = default(zrot, 30);
_xrot = default(xrot, 60);
_z = default(z, 15);
camera = is_undef(distance) && is_undef(zrot) && is_undef(z) &&
is_undef(xrot)
? "--viewall"
: str("--camera 0,0,", _z, ",", _xrot, ",0,", _zrot, ",",
_distance);
if ($content_inventory == "all")
echo("PART", name);
else if ($content_inventory == "png" && png)
echo("PART", name, camera);
else if ($content_inventory == "stl" && stl)
echo("PART", name);
}
}
AM
Adrian Mariano
Fri, May 9, 2025 10:24 AM
If I understand your goal, which seems a little bit hidden by your code
example including extraneous stuff, the code below may do what you want.
The input to show_some should be an array which lists the indices by child
number of what to show. If instead you meant that individual parts of
labels, like this part is called "widget" and that part is called "hinge"
then to do that, the individual parts need to respond to a signal to
display themselves or not. You can send information into the child about
its context that it can use to decide if it should display, but you cannot
get information out of the child.
module show_some(show){
for(i=[0:1:$children-1])
if(search([i],show)!=[[]]){
echo(i);
children(i);
}
}
show_some([0,2]){
text("0");
right(10)text("1");
right(20)text("2");
}
On Fri, May 9, 2025 at 5:04 AM Roel Vanhout via Discuss <
discuss@lists.openscad.org> wrote:
Hello all,
A long time ago, I got the code below from someone on this list to
facilitate having multiple parts in a .scad file and easily switch between
them / have them laid out with spacing in between / export them as separate
parts. Basically you use it like this:
$content_selected = "part1"; // "all" for all parts
contents() {
item("part1") part1();
item("part2") part2();
}
and this will only show the module part1. Now what I would like to do is
add the option for $content_selected to (optionally) be an array and select
multiple parts to be shown at once, without showing all. What I'm running
into is that I would need some way to access a "property" of children(i) in
the code below that has that item()'s value that was passed in as the
"name" parameter. I don't think there is a way for modules to export their
internal parameters though, so I'm wondering if anyone has an idea on how
to work around this, or some other approach to solving this problem. Thanks.
regards
Roel
module contents(d = 120) {
nx = ceil(sqrt($children));
ny = ceil($children/nx);
for (xi=[0:nx-1], yi=[0:ny-1]) {
i = xi + yi * nx;
if (i < $children) {
if (is_undef($content_selected) || $content_selected == "all")
{
translate([xi * d, yi * d, 0]) children(i);
} else {
children(i);
}
}
}
}
module item(name, png = true, stl = true, distance, xrot, zrot, z) {
if (is_undef($content_inventory)) {
if (is_undef($content_selected) || $content_selected == "all" ||
$content_selected == name) {
echo(str("Exporting ", name));
children();
}
} else {
_distance = default(distance, 150);
_zrot = default(zrot, 30);
_xrot = default(xrot, 60);
_z = default(z, 15);
camera = is_undef(distance) && is_undef(zrot) && is_undef(z) &&
is_undef(xrot)
? "--viewall"
: str("--camera 0,0,", _z, ",", _xrot, ",0,", _zrot, ",",
_distance);
if ($content_inventory == "all")
echo("PART", name);
else if ($content_inventory == "png" && png)
echo("PART", name, camera);
else if ($content_inventory == "stl" && stl)
echo("PART", name);
}
}
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
If I understand your goal, which seems a little bit hidden by your code
example including extraneous stuff, the code below may do what you want.
The input to show_some should be an array which lists the indices by child
number of what to show. If instead you meant that individual parts of
labels, like this part is called "widget" and that part is called "hinge"
then to do that, the individual parts need to respond to a signal to
display themselves or not. You can send information into the child about
its context that it can use to decide if it should display, but you cannot
get information out of the child.
module show_some(show){
for(i=[0:1:$children-1])
if(search([i],show)!=[[]]){
echo(i);
children(i);
}
}
show_some([0,2]){
text("0");
right(10)text("1");
right(20)text("2");
}
On Fri, May 9, 2025 at 5:04 AM Roel Vanhout via Discuss <
discuss@lists.openscad.org> wrote:
> Hello all,
>
> A long time ago, I got the code below from someone on this list to
> facilitate having multiple parts in a .scad file and easily switch between
> them / have them laid out with spacing in between / export them as separate
> parts. Basically you use it like this:
>
> $content_selected = "part1"; // "all" for all parts
> contents() {
> item("part1") part1();
> item("part2") part2();
> }
>
> and this will only show the module part1. Now what I would like to do is
> add the option for $content_selected to (optionally) be an array and select
> multiple parts to be shown at once, without showing all. What I'm running
> into is that I would need some way to access a "property" of children(i) in
> the code below that has that item()'s value that was passed in as the
> "name" parameter. I don't think there is a way for modules to export their
> internal parameters though, so I'm wondering if anyone has an idea on how
> to work around this, or some other approach to solving this problem. Thanks.
>
> regards
>
> Roel
>
>
>
> module contents(d = 120) {
> nx = ceil(sqrt($children));
> ny = ceil($children/nx);
> for (xi=[0:nx-1], yi=[0:ny-1]) {
> i = xi + yi * nx;
> if (i < $children) {
> if (is_undef($content_selected) || $content_selected == "all")
> {
> translate([xi * d, yi * d, 0]) children(i);
> } else {
> children(i);
> }
> }
> }
> }
>
> module item(name, png = true, stl = true, distance, xrot, zrot, z) {
> if (is_undef($content_inventory)) {
> if (is_undef($content_selected) || $content_selected == "all" ||
> $content_selected == name) {
> echo(str("Exporting ", name));
> children();
> }
> } else {
> _distance = default(distance, 150);
> _zrot = default(zrot, 30);
> _xrot = default(xrot, 60);
> _z = default(z, 15);
> camera = is_undef(distance) && is_undef(zrot) && is_undef(z) &&
> is_undef(xrot)
> ? "--viewall"
> : str("--camera 0,0,", _z, ",", _xrot, ",0,", _zrot, ",",
> _distance);
> if ($content_inventory == "all")
> echo("PART", name);
> else if ($content_inventory == "png" && png)
> echo("PART", name, camera);
> else if ($content_inventory == "stl" && stl)
> echo("PART", name);
> }
> }
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
JB
Jordan Brown
Fri, May 9, 2025 7:12 PM
On 5/9/2025 2:04 AM, Roel Vanhout via Discuss wrote:
A long time ago, I got the code below from someone on this list to
facilitate having multiple parts in a .scad file and easily switch
between them / have them laid out with spacing in between / export
them as separate parts.
and this will only show the module part1. Now what I would like to do
is add the option for $content_selected to (optionally) be an array
and select multiple parts to be shown at once, without showing all.
OK. What I've usually done for that case is to create a new "part" that
includes multiple subcomponents, e.g.
item("part12") { part1(); part2(); }
But what you're asking for is plausible and more flexible.
What I'm running into is that I would need some way to access a
"property" of children(i) in the code below that has that item()'s
value that was passed in as the "name" parameter. I don't think there
is a way for modules to export their internal parameters though, so
I'm wondering if anyone has an idea on how to work around this, or
some other approach to solving this problem. Thanks.
There's no way to get information out of a module. (More generally,
there's no way to get information out of a scope, except function return
values.)
If you look carefully, you'll see that item() is the thing that decides
whether or not to build a particular item. Every item() gets called,
but only the selected one actually generates anything. Here's the key part:
if (is_undef($content_selected) || $content_selected == "all"
|| $content_selected == name) {
echo(str("Exporting ", name));
children();
}
You'd need to change that "if" to add a test for whether "name" is in
the $content_selected array. You could use search() as Adrian suggests,
or something like
function inlist(list, val) = len([for (v = list) if (v == val) 1 ]) > 0;
... || (is_list($content_selected) && inlist($content_selected, name))
If you do this, if you look at contents() you will see that it will
generate all of the selected items at the origin. It seems like that's
probably what you want, but if not then you'll need more work there.
On 5/9/2025 2:04 AM, Roel Vanhout via Discuss wrote:
> A long time ago, I got the code below from someone on this list to
> facilitate having multiple parts in a .scad file and easily switch
> between them / have them laid out with spacing in between / export
> them as separate parts.
That would be me.
> and this will only show the module part1. Now what I would like to do
> is add the option for $content_selected to (optionally) be an array
> and select multiple parts to be shown at once, without showing all.
OK. What I've usually done for that case is to create a new "part" that
includes multiple subcomponents, e.g.
item("part12") { part1(); part2(); }
But what you're asking for is plausible and more flexible.
> What I'm running into is that I would need some way to access a
> "property" of children(i) in the code below that has that item()'s
> value that was passed in as the "name" parameter. I don't think there
> is a way for modules to export their internal parameters though, so
> I'm wondering if anyone has an idea on how to work around this, or
> some other approach to solving this problem. Thanks.
There's no way to get information out of a module. (More generally,
there's no way to get information out of a scope, except function return
values.)
If you look carefully, you'll see that item() is the thing that decides
whether or not to build a particular item. Every item() gets called,
but only the selected one actually generates anything. Here's the key part:
> if (is_undef($content_selected) || $content_selected == "all"
> || $content_selected == name) {
> echo(str("Exporting ", name));
> children();
> }
You'd need to change that "if" to add a test for whether "name" is in
the $content_selected array. You could use search() as Adrian suggests,
or something like
function inlist(list, val) = len([for (v = list) if (v == val) 1 ]) > 0;
... || (is_list($content_selected) && inlist($content_selected, name))
If you do this, if you look at contents() you will see that it will
generate all of the selected items at the origin. It seems like that's
probably what you want, but if not then you'll need more work there.
GH
gene heskett
Sat, May 10, 2025 1:41 AM
On 5/9/25 15:12, Jordan Brown via Discuss wrote:
On 5/9/2025 2:04 AM, Roel Vanhout via Discuss wrote:
A long time ago, I got the code below from someone on this list to
facilitate having multiple parts in a .scad file and easily switch
between them / have them laid out with spacing in between / export
them as separate parts.
and this will only show the module part1. Now what I would like to do
is add the option for $content_selected to (optionally) be an array
and select multiple parts to be shown at once, without showing all.
OK. What I've usually done for that case is to create a new "part" that
includes multiple subcomponents, e.g.
item("part12") { part1(); part2(); }
But what you're asking for is plausible and more flexible.
I have done some of that, by making a module that includes the modules I
want, building by variable passed, data which builds a 5 part hotend
carriage for a 3d printer, or breaks it down into 5 individual pieces
that print separately in one printing, then assemble. The method seems
quite amenable to making mulltiple parts whose bolt holes align
perfectly. And I do that with the weekly AppImage build, no libraries
called in. Pure OpenSCAD.
What I'm running into is that I would need some way to access a
"property" of children(i) in the code below that has that item()'s
value that was passed in as the "name" parameter. I don't think there
is a way for modules to export their internal parameters though,
That is controlled by the scope of the variable as its defined.
I'm wondering if anyone has an idea on how to work around this, or
some other approach to solving this problem. Thanks.
There's no way to get information out of a module. (More generally,
there's no way to get information out of a scope, except function return
values.)
If you look carefully, you'll see that item() is the thing that decides
whether or not to build a particular item. Every item() gets called,
but only the selected one actually generates anything. Here's the key part:
if (is_undef($content_selected) || $content_selected == "all"
|| $content_selected == name) {
echo(str("Exporting ", name));
children();
}
You'd need to change that "if" to add a test for whether "name" is in
the $content_selected array. You could use search() as Adrian suggests,
or something like
function inlist(list, val) = len([for (v = list) if (v == val) 1 ]) > 0;
... || (is_list($content_selected) && inlist($content_selected, name))
If you do this, if you look at contents() you will see that it will
generate all of the selected items at the origin. It seems like that's
probably what you want, but if not then you'll need more work there.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Cheers, Gene Heskett, CET.
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
On 5/9/25 15:12, Jordan Brown via Discuss wrote:
> On 5/9/2025 2:04 AM, Roel Vanhout via Discuss wrote:
>> A long time ago, I got the code below from someone on this list to
>> facilitate having multiple parts in a .scad file and easily switch
>> between them / have them laid out with spacing in between / export
>> them as separate parts.
> That would be me.
>
>> and this will only show the module part1. Now what I would like to do
>> is add the option for $content_selected to (optionally) be an array
>> and select multiple parts to be shown at once, without showing all.
> OK. What I've usually done for that case is to create a new "part" that
> includes multiple subcomponents, e.g.
>
> item("part12") { part1(); part2(); }
>
> But what you're asking for is plausible and more flexible.
I have done some of that, by making a module that includes the modules I
want, building by variable passed, data which builds a 5 part hotend
carriage for a 3d printer, or breaks it down into 5 individual pieces
that print separately in one printing, then assemble. The method seems
quite amenable to making mulltiple parts whose bolt holes align
perfectly. And I do that with the weekly AppImage build, no libraries
called in. Pure OpenSCAD.
>> What I'm running into is that I would need some way to access a
>> "property" of children(i) in the code below that has that item()'s
>> value that was passed in as the "name" parameter. I don't think there
>> is a way for modules to export their internal parameters though,
That is controlled by the scope of the variable as its defined.
>> I'm wondering if anyone has an idea on how to work around this, or
>> some other approach to solving this problem. Thanks.
> There's no way to get information out of a module. (More generally,
> there's no way to get information out of a scope, except function return
> values.)
>
> If you look carefully, you'll see that item() is the thing that decides
> whether or not to build a particular item. Every item() gets called,
> but only the selected one actually generates anything. Here's the key part:
>
>> if (is_undef($content_selected) || $content_selected == "all"
>> || $content_selected == name) {
>> echo(str("Exporting ", name));
>> children();
>> }
> You'd need to change that "if" to add a test for whether "name" is in
> the $content_selected array. You could use search() as Adrian suggests,
> or something like
>
> function inlist(list, val) = len([for (v = list) if (v == val) 1 ]) > 0;
>
>
> ... || (is_list($content_selected) && inlist($content_selected, name))
>
> If you do this, if you look at contents() you will see that it will
> generate all of the selected items at the origin. It seems like that's
> probably what you want, but if not then you'll need more work there.
>
>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
Cheers, Gene Heskett, CET.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
JB
Jon Bondy
Sat, May 10, 2025 11:10 AM
Libraries are pure OpenSCAD, just organized so that many people can take
advantage of the code
On 5/9/2025 9:41 PM, gene heskett via Discuss wrote:
I have done some of that, by making a module that includes the modules
I want, building by variable passed, data which builds a 5 part hotend
carriage for a 3d printer, or breaks it down into 5 individual pieces
that print separately in one printing, then assemble. The method seems
quite amenable to making mulltiple parts whose bolt holes align
perfectly. And I do that with the weekly AppImage build, no libraries
called in. Pure OpenSCAD.
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
Libraries are pure OpenSCAD, just organized so that many people can take
advantage of the code
On 5/9/2025 9:41 PM, gene heskett via Discuss wrote:
> I have done some of that, by making a module that includes the modules
> I want, building by variable passed, data which builds a 5 part hotend
> carriage for a 3d printer, or breaks it down into 5 individual pieces
> that print separately in one printing, then assemble. The method seems
> quite amenable to making mulltiple parts whose bolt holes align
> perfectly. And I do that with the weekly AppImage build, no libraries
> called in. Pure OpenSCAD.
>
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
GH
gene heskett
Sat, May 10, 2025 12:38 PM
On 5/10/25 07:10, Jon Bondy via Discuss wrote:
Libraries are pure OpenSCAD, just organized so that many people can
take advantage of the code
However Jon, libraries such as BOSL2, don't have the on screen quick
reference to tell one how to use them w/o resorting to a web browser on
another workspace. This messes with my "train of thought" and usually
results in my doing what I want w/o the help of the library. Blame some
of that on my 90 yo thinker & you will be pretty close to the mark. That
and 80 years of chasing electrons to make them do what I want. That I
have been rather good at. Besides, gotta have something to keep me out
of the bars in my dotage since my diabetes precludes that. ;o)>
On 5/9/2025 9:41 PM, gene heskett via Discuss wrote:
I have done some of that, by making a module that includes the
modules I want, building by variable passed, data which builds a 5
part hotend carriage for a 3d printer, or breaks it down into 5
individual pieces that print separately in one printing, then
assemble. The method seems quite amenable to making mulltiple parts
whose bolt holes align perfectly. And I do that with the weekly
AppImage build, no libraries called in. Pure OpenSCAD.
Cheers, Gene Heskett, CET.
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
On 5/10/25 07:10, Jon Bondy via Discuss wrote:
> Libraries are pure OpenSCAD, just organized so that many people can
> take advantage of the code
However Jon, libraries such as BOSL2, don't have the on screen quick
reference to tell one how to use them w/o resorting to a web browser on
another workspace. This messes with my "train of thought" and usually
results in my doing what I want w/o the help of the library. Blame some
of that on my 90 yo thinker & you will be pretty close to the mark. That
and 80 years of chasing electrons to make them do what I want. That I
have been rather good at. Besides, gotta have something to keep me out
of the bars in my dotage since my diabetes precludes that. ;o)>
>
> On 5/9/2025 9:41 PM, gene heskett via Discuss wrote:
>> I have done some of that, by making a module that includes the
>> modules I want, building by variable passed, data which builds a 5
>> part hotend carriage for a 3d printer, or breaks it down into 5
>> individual pieces that print separately in one printing, then
>> assemble. The method seems quite amenable to making mulltiple parts
>> whose bolt holes align perfectly. And I do that with the weekly
>> AppImage build, no libraries called in. Pure OpenSCAD.
>>
>
Cheers, Gene Heskett, CET.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
JB
Jon Bondy
Sat, May 10, 2025 1:39 PM
Gene:
Understood, but were you to create a library to perform the magic you
described, then the rest of us would benefit.
I find most libraries to not be worth the time to learn. BOSL2 has such
excellent documentation, with useful examples, that it is the first
place I go when I need something. For example, I just discovered their
hinges, with gratitude.
Jon
On 5/10/2025 8:38 AM, gene heskett via Discuss wrote:
On 5/10/25 07:10, Jon Bondy via Discuss wrote:
Libraries are pure OpenSCAD, just organized so that many people can
take advantage of the code
However Jon, libraries such as BOSL2, don't have the on screen quick
reference to tell one how to use them w/o resorting to a web browser
on another workspace. This messes with my "train of thought" and
usually results in my doing what I want w/o the help of the library.
Blame some of that on my 90 yo thinker & you will be pretty close to
the mark. That and 80 years of chasing electrons to make them do what
I want. That I have been rather good at. Besides, gotta have
something to keep me out of the bars in my dotage since my diabetes
precludes that. ;o)>
On 5/9/2025 9:41 PM, gene heskett via Discuss wrote:
I have done some of that, by making a module that includes the
modules I want, building by variable passed, data which builds a 5
part hotend carriage for a 3d printer, or breaks it down into 5
individual pieces that print separately in one printing, then
assemble. The method seems quite amenable to making mulltiple parts
whose bolt holes align perfectly. And I do that with the weekly
AppImage build, no libraries called in. Pure OpenSCAD.
Cheers, Gene Heskett, CET.
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
Gene:
Understood, but were you to create a library to perform the magic you
described, then the rest of us would benefit.
I find most libraries to not be worth the time to learn. BOSL2 has such
excellent documentation, with useful examples, that it is the first
place I go when I need something. For example, I just discovered their
hinges, with gratitude.
Jon
On 5/10/2025 8:38 AM, gene heskett via Discuss wrote:
> On 5/10/25 07:10, Jon Bondy via Discuss wrote:
>> Libraries are pure OpenSCAD, just organized so that many people can
>> take advantage of the code
> However Jon, libraries such as BOSL2, don't have the on screen quick
> reference to tell one how to use them w/o resorting to a web browser
> on another workspace. This messes with my "train of thought" and
> usually results in my doing what I want w/o the help of the library.
> Blame some of that on my 90 yo thinker & you will be pretty close to
> the mark. That and 80 years of chasing electrons to make them do what
> I want. That I have been rather good at. Besides, gotta have
> something to keep me out of the bars in my dotage since my diabetes
> precludes that. ;o)>
>>
>> On 5/9/2025 9:41 PM, gene heskett via Discuss wrote:
>>> I have done some of that, by making a module that includes the
>>> modules I want, building by variable passed, data which builds a 5
>>> part hotend carriage for a 3d printer, or breaks it down into 5
>>> individual pieces that print separately in one printing, then
>>> assemble. The method seems quite amenable to making mulltiple parts
>>> whose bolt holes align perfectly. And I do that with the weekly
>>> AppImage build, no libraries called in. Pure OpenSCAD.
>>>
>>
> Cheers, Gene Heskett, CET.
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
GH
gene heskett
Sat, May 10, 2025 4:48 PM
On 5/10/25 09:40, Jon Bondy wrote:
Gene:
Understood, but were you to create a library to perform the magic you
described, then the rest of us would benefit.
Likely true. but the creation is so easy. The hard part is the first
bolt, then another module creates 4 of them, usually in a rectangular
spacing pattern. Then when you need that bolt pattern, include the 4
bolt version, rotating and translating it to where ever its needed. 10
minutes to put that bolt pattern anyplace its needed once written.
Working in PETG, I don't consider the threads. The printer makes a hole
.45mm smaller than specified, so I increase the size of the hole by .5mm
for clearance, or .2mm if its to be self threading, usually for 3 or 4
mm cap screws. At 5 threads into the plastic its self locking and well
threaded. I could likely pull the cap off the screw before the threads
it makes in the PETG fail.
I find most libraries to not be worth the time to learn. BOSL2 has
such excellent documentation, with useful examples, that it is the
first place I go when I need something. For example, I just
discovered their hinges, with gratitude.
I didn't know it could do that. When I needed to make a 7 degree to do a
buttress thread with the side of a .0625" by .250" round nose mill,
using the rounded nose as a fillet, I considered a hinge under the
spindle motor, something I could adjust, but given the inevitable slop,
I wound up just making a solid 7 degree wedge, which 3 years later is
still installed. Makes beautiful buttress threads in hard maple using
gcode I wrote myself. I write ALL the gcode I need, no CAD involved. I
do use a bit of python to cut any sized holes on the milling machine
which is as close to CAD as I get. linuxcnc is very picky about arcs, it
its off a micron it won't accept it.
That box we're supposed to stay in? It got cut up and fed to the
fireplace back in the late 40's of the last century. . . OpenSCAD fits
my thinking methods, flawlessly, thank you ALL.
The only thing it doesn't do is Einsteins relativity, but our machines
don't move fast enough to matter. But I had to explain that to the FCC
in regard to a time distortion we didn't know how to precompensate for
back in the 1970's, imposed by the klystron amplifiers us UHF
broadcasters used at the time. We've since developed both shorter
amplifiers and precomp methods, which work or we'd not have digital hdtv
today. Adequately explaining that would take a couple more paragraphs,
but has to do with an electron beam about 4 feet long and the mass
increase of said electron when moving at a measurable small fraction of
C speed due to the 20 kilovolts applied. The tube length effectively
grows with the power level of the then NTSC signal.. All of which is
off-topic for this list. But I can continue in more detail if there is
an interest.
[...]
Cheers, Gene Heskett, CET.
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
On 5/10/25 09:40, Jon Bondy wrote:
> Gene:
>
> Understood, but were you to create a library to perform the magic you
> described, then the rest of us would benefit.
Likely true. but the creation is so easy. The hard part is the first
bolt, then another module creates 4 of them, usually in a rectangular
spacing pattern. Then when you need that bolt pattern, include the 4
bolt version, rotating and translating it to where ever its needed. 10
minutes to put that bolt pattern anyplace its needed once written.
Working in PETG, I don't consider the threads. The printer makes a hole
.45mm smaller than specified, so I increase the size of the hole by .5mm
for clearance, or .2mm if its to be self threading, usually for 3 or 4
mm cap screws. At 5 threads into the plastic its self locking and well
threaded. I could likely pull the cap off the screw before the threads
it makes in the PETG fail.
> I find most libraries to not be worth the time to learn. BOSL2 has
> such excellent documentation, with useful examples, that it is the
> first place I go when I need something. For example, I just
> discovered their hinges, with gratitude.
I didn't know it could do that. When I needed to make a 7 degree to do a
buttress thread with the side of a .0625" by .250" round nose mill,
using the rounded nose as a fillet, I considered a hinge under the
spindle motor, something I could adjust, but given the inevitable slop,
I wound up just making a solid 7 degree wedge, which 3 years later is
still installed. Makes beautiful buttress threads in hard maple using
gcode I wrote myself. I write ALL the gcode I need, no CAD involved. I
do use a bit of python to cut any sized holes on the milling machine
which is as close to CAD as I get. linuxcnc is very picky about arcs, it
its off a micron it won't accept it.
That box we're supposed to stay in? It got cut up and fed to the
fireplace back in the late 40's of the last century. . . OpenSCAD fits
my thinking methods, flawlessly, thank you ALL.
The only thing it doesn't do is Einsteins relativity, but our machines
don't move fast enough to matter. But I had to explain that to the FCC
in regard to a time distortion we didn't know how to precompensate for
back in the 1970's, imposed by the klystron amplifiers us UHF
broadcasters used at the time. We've since developed both shorter
amplifiers and precomp methods, which work or we'd not have digital hdtv
today. Adequately explaining that would take a couple more paragraphs,
but has to do with an electron beam about 4 feet long and the mass
increase of said electron when moving at a measurable small fraction of
C speed due to the 20 kilovolts applied. The tube length effectively
grows with the power level of the then NTSC signal.. All of which is
off-topic for this list. But I can continue in more detail if there is
an interest.
> Jon
[...]
Cheers, Gene Heskett, CET.
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.
- Louis D. Brandeis
RV
Roel Vanhout
Wed, May 14, 2025 8:27 AM
On 5/9/2025 2:04 AM, Roel Vanhout via Discuss wrote:
A long time ago, I got the code below from someone on this list to facilitate having multiple parts in a .scad file and easily switch between them / have them laid out with spacing in between / export them as separate parts.
Ah thank you, sorry I had forgotten that it came from you, but I have
used it many times since, very useful, thanks :) I did post the entire
thing to give some context, it seems to me that something like this
would be so universally required that it may warrant submission to
BOSL? It feels very closely related to distributors.scad from there.
If you look carefully, you'll see that item() is the thing that decides whether or not to build a particular item. Every item() gets called, but only the selected one actually generates anything. Here's the key part:
if (is_undef($content_selected) || $content_selected == "all" || $content_selected == name) {
echo(str("Exporting ", name));
children();
}
You'd need to change that "if" to add a test for whether "name" is in the $content_selected array. You could use search() as Adrian suggests, or something like
function inlist(list, val) = len([for (v = list) if (v == val) 1 ]) > 0;
... || (is_list($content_selected) && inlist($content_selected, name))
If you do this, if you look at contents() you will see that it will generate all of the selected items at the origin. It seems like that's probably what you want, but if not then you'll need more work there.
Yes indeed, I had gotten this far, but the devil is in the details of
the 'more work' mentioned :) I do want to layout separate pieces in a
grid just like if these modules would be the only ones that are listed
(so if I have 4 items, and I want to show the 3rd and 4th, they would
be laid out on the X axis, instead of being offset along the Y axis
and the spots where items 1 and 2 would be, left blank), but if I add
only the appropriate is_list() and inlist() checks to both the
contents() and the item() modules, the parts that are not selected are
just skipped over and their spot in the grid left blank, so to speak.
(My next enhancement would be to add multiple layout modes - in a
line, in a grid, maybe some convenient way to do exploded views of
assemblies). But it seems like a fundamental problem that there is no
way to get the 'name' from an item() inside contents(), and there is
also no way to keep track of the howmanyeth item we're are currently
at within contents() (so that we can pass it to item() with a $
variable), which are overall the two main approaches I think exist.
I've played around with various workarounds with wrapper modules and
so on but they all require passing extra information to either
contents() or item() at some point, which severely degrades usability
because you have to repeat your selection of items.
My next usability thing would be to only have to specify module names
ones, so instead of having to write item("hook") hook(); for each
part, I could just write item("hook") and the item() module would
instantiate a module named "hook", but again there doesn't seem to be
a way to do this sort of dynamic instantiation of modules. I think it
(as well as my previous, original problem) could be solved with some
metaprogramming in a preprocessor, but I guess it would be too much to
ask to have one of those included in OpenSCAD :)
regards
Roel
> On Fri, May 9, 2025 at 9:12 PM Jordan Brown <openscad@jordan.maileater.net> wrote:
>> On 5/9/2025 2:04 AM, Roel Vanhout via Discuss wrote:
>> A long time ago, I got the code below from someone on this list to facilitate having multiple parts in a .scad file and easily switch between them / have them laid out with spacing in between / export them as separate parts.
> That would be me.
Ah thank you, sorry I had forgotten that it came from you, but I have
used it many times since, very useful, thanks :) I did post the entire
thing to give some context, it seems to me that something like this
would be so universally required that it may warrant submission to
BOSL? It feels very closely related to distributors.scad from there.
> If you look carefully, you'll see that item() is the thing that decides whether or not to build a particular item. Every item() gets called, but only the selected one actually generates anything. Here's the key part:
> if (is_undef($content_selected) || $content_selected == "all" || $content_selected == name) {
> echo(str("Exporting ", name));
> children();
> }
> You'd need to change that "if" to add a test for whether "name" is in the $content_selected array. You could use search() as Adrian suggests, or something like
> function inlist(list, val) = len([for (v = list) if (v == val) 1 ]) > 0;
> ... || (is_list($content_selected) && inlist($content_selected, name))
> If you do this, if you look at contents() you will see that it will generate all of the selected items at the origin. It seems like that's probably what you want, but if not then you'll need more work there.
Yes indeed, I had gotten this far, but the devil is in the details of
the 'more work' mentioned :) I do want to layout separate pieces in a
grid just like if these modules would be the only ones that are listed
(so if I have 4 items, and I want to show the 3rd and 4th, they would
be laid out on the X axis, instead of being offset along the Y axis
and the spots where items 1 and 2 would be, left blank), but if I add
only the appropriate is_list() and inlist() checks to both the
contents() and the item() modules, the parts that are not selected are
just skipped over and their spot in the grid left blank, so to speak.
(My next enhancement would be to add multiple layout modes - in a
line, in a grid, maybe some convenient way to do exploded views of
assemblies). But it seems like a fundamental problem that there is no
way to get the 'name' from an item() inside contents(), and there is
also no way to keep track of the howmanyeth item we're are currently
at within contents() (so that we can pass it to item() with a $
variable), which are overall the two main approaches I think exist.
I've played around with various workarounds with wrapper modules and
so on but they all require passing extra information to either
contents() or item() at some point, which severely degrades usability
because you have to repeat your selection of items.
My next usability thing would be to only have to specify module names
ones, so instead of having to write item("hook") hook(); for each
part, I could just write item("hook") and the item() module would
instantiate a module named "hook", but again there doesn't seem to be
a way to do this sort of dynamic instantiation of modules. I think it
(as well as my previous, original problem) could be solved with some
metaprogramming in a preprocessor, but I guess it would be too much to
ask to have one of those included in OpenSCAD :)
regards
Roel
JB
Jordan Brown
Wed, May 14, 2025 3:33 PM
On 5/14/2025 1:27 AM, Roel Vanhout wrote:
I do want to layout separate pieces in a grid just like if these
modules would be the only ones that are listed (so if I have 4 items,
and I want to show the 3rd and 4th, they would be laid out on the X
axis, instead of being offset along the Y axis and the spots where
items 1 and 2 would be, left blank), but if I add only the appropriate
is_list() and inlist() checks to both the contents() and the item()
modules, the parts that are not selected are just skipped over and
their spot in the grid left blank, so to speak.
Yeah, can't avoid that with this scheme. Only the child item() subtrees
know whether or not they are generated, and only the parent contents()
knows where the children are positioned.
(My next enhancement would be to add multiple layout modes - in a
line, in a grid,
The grid supported by contents() is rudimentary, a way to provide an
overview of the parts.
maybe some convenient way to do exploded views of assemblies).
Exploded views are not as easy as you might think, because the position
of everything depends on the position of everything else, sometimes in
contradictory ways.
But it seems like a fundamental problem that there is no
way to get the 'name' from an item() inside contents(),
Correct, there is no way. OpenSCAD children (and in general OpenSCAD
scopes) are black holes; no information can escape.
and there is also no way to keep track of the howmanyeth item we're
are currently at within contents() (so that we can pass it to item()
with a $ variable),
Also correct, again because the children are black holes and won't tell
you whether or not they are being generated.
You can imagine giving the list of names to contents() and having it do
the on/off selection. But that's ugly from a modularity standpoint,
having to maintain two parallel lists. (As you mention elsewhere.)
PR#4478 (don't hold your breath) offers some additional options - in
particular, using module references.
there doesn't seem to be a way to do this sort of dynamic instantiation of modules.
On 5/14/2025 1:27 AM, Roel Vanhout wrote:
>
> I do want to layout separate pieces in a grid just like if these
> modules would be the only ones that are listed (so if I have 4 items,
> and I want to show the 3rd and 4th, they would be laid out on the X
> axis, instead of being offset along the Y axis and the spots where
> items 1 and 2 would be, left blank), but if I add only the appropriate
> is_list() and inlist() checks to both the contents() and the item()
> modules, the parts that are not selected are just skipped over and
> their spot in the grid left blank, so to speak.
>
Yeah, can't avoid that with this scheme. Only the child item() subtrees
know whether or not they are generated, and only the parent contents()
knows where the children are positioned.
> (My next enhancement would be to add multiple layout modes - in a
> line, in a grid,
>
The grid supported by contents() is rudimentary, a way to provide an
overview of the parts.
> maybe some convenient way to do exploded views of assemblies).
Exploded views are not as easy as you might think, because the position
of everything depends on the position of everything else, sometimes in
contradictory ways.
> But it seems like a fundamental problem that there is no
> way to get the 'name' from an item() inside contents(),
Correct, there is no way. OpenSCAD children (and in general OpenSCAD
scopes) are black holes; no information can escape.
> and there is also no way to keep track of the howmanyeth item we're
> are currently at within contents() (so that we can pass it to item()
> with a $ variable),
>
Also correct, again because the children are black holes and won't tell
you whether or not they are being generated.
You can imagine giving the list of names to contents() and having it do
the on/off selection. But that's ugly from a modularity standpoint,
having to maintain two parallel lists. (As you mention elsewhere.)
PR#4478 (don't hold your breath) offers some additional options - in
particular, using module references.
> there doesn't seem to be a way to do this sort of dynamic instantiation of modules.
There is not.