discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

My BOSL2 install

GH
gene heskett
Thu, Jun 26, 2025 1:32 PM

I have now unpacked yesterdays BOSL2-master.zip and removed the older
versions from /home/gene/.local/share/OpenSCAD/libraries,

then copied the unpacked BOSL2-master.zip's contents to the above
libraries path as BOSL2, so all files there are now dated today.

Then I re-arranged the file from the original post, and wrapped it as a
"module test();"

So it now looks like this:

module test(); {     include
</home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>     include
</home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>    
difference()cylinder(h=50, d=16, $fn=150);    
translate([0,0,1.5])cylinder(h=32.5, d=12);    
translate([0,0,34])threaded_rod(d=12, l=16, pitch=2, internal=false,
bevel=0.5); } test();

But I am still getting this error for an F5:

Parsing design (AST generation)...

Saved backup file:
/home/gene/.local/share/OpenSCAD/backups/unsaved-backup-aoYvNDoJ.scad

ERROR: Parser error: syntax error in file
.local/share/OpenSCAD/libraries/BOSL2/color.scad, line 14

Execution aborted

With the editor marking the > in red at the end of line 3.

So obviously I am doing something wrong yet, but what? That is (I think)
a valid full path to the libraries.

Problems like this have plagued every attempt I have made to use BOSL2
for the years I've been trying to use bookworm (up to date a/o this past
Sunday) as my daily driver. This install is busted, and its probably
been reinstalled 30+ times because the original installer thought I was
blind and installed orca and brltty with every install and by the time I
had gotten rid of orca and brltty, it was not rebootable without a full
reinstall bdecause it waited forever for orca to come online. I have
finally managed to put a muffler on orca, but for the last 2 years have
been plagued by a 30 second system lockup anytime something asks to run
a gui-fied file selector. Or other similar operations. I cannot use the
best photo manager as it won't wait for that timeout, shotwell does wait
then handles my photo work nicely, so I'm not totally crippled. gimp
waits, runs fine after the wait. And folks on the debian list where I've
been a legendary pain in the a$$ about this haven't a clue what might be
wrong. If trixie doesn't fix it, I'm off to xubuntu, after nearlly 20
years on debian because LinuxCNC is built to run on debian, and I carve
both metal and wood with it on 4 CNC'd machines here, but then I'll have
to figure out how to run this stuff on ubuntu.

LinuxCNC has to have at a minimum of a preempt-rt kernel.

Not your problem, IRQ latency's under 50 u-secs, even on the rpi4b that
runs my 11x54 sheldon lathe, just background requirements here.

Thank you.

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
I have now unpacked yesterdays BOSL2-master.zip and removed the older versions from /home/gene/.local/share/OpenSCAD/libraries, then copied the unpacked BOSL2-master.zip's contents to the above libraries path as BOSL2, so all files there are now dated today. Then I re-arranged the file from the original post, and wrapped it as a "module test();" So it now looks like this: module test(); {     include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>     include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>     difference()cylinder(h=50, d=16, $fn=150);     translate([0,0,1.5])cylinder(h=32.5, d=12);     translate([0,0,34])threaded_rod(d=12, l=16, pitch=2, internal=false, bevel=0.5); } test(); But I am still getting this error for an F5: Parsing design (AST generation)... Saved backup file: /home/gene/.local/share/OpenSCAD/backups/unsaved-backup-aoYvNDoJ.scad ERROR: Parser error: syntax error in file .local/share/OpenSCAD/libraries/BOSL2/color.scad, line 14 Execution aborted With the editor marking the > in red at the end of line 3. So obviously I am doing something wrong yet, but what? That is (I think) a valid full path to the libraries. Problems like this have plagued every attempt I have made to use BOSL2 for the years I've been trying to use bookworm (up to date a/o this past Sunday) as my daily driver. This install is busted, and its probably been reinstalled 30+ times because the original installer thought I was blind and installed orca and brltty with every install and by the time I had gotten rid of orca and brltty, it was not rebootable without a full reinstall bdecause it waited forever for orca to come online. I have finally managed to put a muffler on orca, but for the last 2 years have been plagued by a 30 second system lockup anytime something asks to run a gui-fied file selector. Or other similar operations. I cannot use the best photo manager as it won't wait for that timeout, shotwell does wait then handles my photo work nicely, so I'm not totally crippled. gimp waits, runs fine after the wait. And folks on the debian list where I've been a legendary pain in the a$$ about this haven't a clue what might be wrong. If trixie doesn't fix it, I'm off to xubuntu, after nearlly 20 years on debian because LinuxCNC is built to run on debian, and I carve both metal and wood with it on 4 CNC'd machines here, but then I'll have to figure out how to run this stuff on ubuntu. LinuxCNC has to have at a minimum of a preempt-rt kernel. Not your problem, IRQ latency's under 50 u-secs, even on the rpi4b that runs my 11x54 sheldon lathe, just background requirements here. Thank you. 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
LM
Leonard Martin Struttmann
Thu, Jun 26, 2025 3:03 PM

Gene,

Try moving the include statements above (outside) of the module definition.

Len

On Thu, Jun 26, 2025 at 8:32 AM gene heskett via Discuss <
discuss@lists.openscad.org> wrote:

I have now unpacked yesterdays BOSL2-master.zip and removed the older
versions from /home/gene/.local/share/OpenSCAD/libraries,

then copied the unpacked BOSL2-master.zip's contents to the above
libraries path as BOSL2, so all files there are now dated today.

Then I re-arranged the file from the original post, and wrapped it as a
"module test();"

So it now looks like this:

module test(); {    include
</home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>    include
</home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
difference()cylinder(h=50, d=16, $fn=150);
translate([0,0,1.5])cylinder(h=32.5, d=12);
translate([0,0,34])threaded_rod(d=12, l=16, pitch=2, internal=false,
bevel=0.5); } test();

But I am still getting this error for an F5:

Parsing design (AST generation)...

Saved backup file:
/home/gene/.local/share/OpenSCAD/backups/unsaved-backup-aoYvNDoJ.scad

ERROR: Parser error: syntax error in file
.local/share/OpenSCAD/libraries/BOSL2/color.scad, line 14

Execution aborted

With the editor marking the > in red at the end of line 3.

So obviously I am doing something wrong yet, but what? That is (I think)
a valid full path to the libraries.

Problems like this have plagued every attempt I have made to use BOSL2
for the years I've been trying to use bookworm (up to date a/o this past
Sunday) as my daily driver. This install is busted, and its probably
been reinstalled 30+ times because the original installer thought I was
blind and installed orca and brltty with every install and by the time I
had gotten rid of orca and brltty, it was not rebootable without a full
reinstall bdecause it waited forever for orca to come online. I have
finally managed to put a muffler on orca, but for the last 2 years have
been plagued by a 30 second system lockup anytime something asks to run
a gui-fied file selector. Or other similar operations. I cannot use the
best photo manager as it won't wait for that timeout, shotwell does wait
then handles my photo work nicely, so I'm not totally crippled. gimp
waits, runs fine after the wait. And folks on the debian list where I've
been a legendary pain in the a$$ about this haven't a clue what might be
wrong. If trixie doesn't fix it, I'm off to xubuntu, after nearlly 20
years on debian because LinuxCNC is built to run on debian, and I carve
both metal and wood with it on 4 CNC'd machines here, but then I'll have
to figure out how to run this stuff on ubuntu.

LinuxCNC has to have at a minimum of a preempt-rt kernel.

Not your problem, IRQ latency's under 50 u-secs, even on the rpi4b that
runs my 11x54 sheldon lathe, just background requirements here.

Thank you.

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

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

Gene, Try moving the include statements above (outside) of the module definition. Len On Thu, Jun 26, 2025 at 8:32 AM gene heskett via Discuss < discuss@lists.openscad.org> wrote: > I have now unpacked yesterdays BOSL2-master.zip and removed the older > versions from /home/gene/.local/share/OpenSCAD/libraries, > > then copied the unpacked BOSL2-master.zip's contents to the above > libraries path as BOSL2, so all files there are now dated today. > > Then I re-arranged the file from the original post, and wrapped it as a > "module test();" > > So it now looks like this: > > module test(); { include > </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> include > </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> > difference()cylinder(h=50, d=16, $fn=150); > translate([0,0,1.5])cylinder(h=32.5, d=12); > translate([0,0,34])threaded_rod(d=12, l=16, pitch=2, internal=false, > bevel=0.5); } test(); > > But I am still getting this error for an F5: > > Parsing design (AST generation)... > > Saved backup file: > /home/gene/.local/share/OpenSCAD/backups/unsaved-backup-aoYvNDoJ.scad > > ERROR: Parser error: syntax error in file > .local/share/OpenSCAD/libraries/BOSL2/color.scad, line 14 > > Execution aborted > > With the editor marking the > in red at the end of line 3. > > So obviously I am doing something wrong yet, but what? That is (I think) > a valid full path to the libraries. > > Problems like this have plagued every attempt I have made to use BOSL2 > for the years I've been trying to use bookworm (up to date a/o this past > Sunday) as my daily driver. This install is busted, and its probably > been reinstalled 30+ times because the original installer thought I was > blind and installed orca and brltty with every install and by the time I > had gotten rid of orca and brltty, it was not rebootable without a full > reinstall bdecause it waited forever for orca to come online. I have > finally managed to put a muffler on orca, but for the last 2 years have > been plagued by a 30 second system lockup anytime something asks to run > a gui-fied file selector. Or other similar operations. I cannot use the > best photo manager as it won't wait for that timeout, shotwell does wait > then handles my photo work nicely, so I'm not totally crippled. gimp > waits, runs fine after the wait. And folks on the debian list where I've > been a legendary pain in the a$$ about this haven't a clue what might be > wrong. If trixie doesn't fix it, I'm off to xubuntu, after nearlly 20 > years on debian because LinuxCNC is built to run on debian, and I carve > both metal and wood with it on 4 CNC'd machines here, but then I'll have > to figure out how to run this stuff on ubuntu. > > LinuxCNC has to have at a minimum of a preempt-rt kernel. > > Not your problem, IRQ latency's under 50 u-secs, even on the rpi4b that > runs my 11x54 sheldon lathe, just background requirements here. > > Thank you. > > 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 > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
GH
gene heskett
Thu, Jun 26, 2025 3:48 PM

On 6/26/25 09:32, gene heskett via Discuss wrote:

I have now unpacked yesterdays BOSL2-master.zip and removed the older
versions from /home/gene/.local/share/OpenSCAD/libraries,

then copied the unpacked BOSL2-master.zip's contents to the above
libraries path as BOSL2, so all files there are now dated today.

Then I re-arranged the file from the original post, and wrapped it as
a "module test();"

So it now looks like this:

module test(); {     include
</home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>    
include
</home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>    
difference()cylinder(h=50, d=16, $fn=150);
translate([0,0,1.5])cylinder(h=32.5, d=12);
translate([0,0,34])threaded_rod(d=12, l=16, pitch=2, internal=false,
bevel=0.5); } test();

And the formatting has been totally removed.  WTF?????

But I am still getting this error for an F5:

Parsing design (AST generation)...

Saved backup file:
/home/gene/.local/share/OpenSCAD/backups/unsaved-backup-aoYvNDoJ.scad

ERROR: Parser error: syntax error in file
.local/share/OpenSCAD/libraries/BOSL2/color.scad, line 14

Execution aborted

With the editor marking the > in red at the end of line 3.

So obviously I am doing something wrong yet, but what? That is (I
think) a valid full path to the libraries.

Problems like this have plagued every attempt I have made to use BOSL2
for the years I've been trying to use bookworm (up to date a/o this
past Sunday) as my daily driver. This install is busted, and its
probably been reinstalled 30+ times because the original installer
thought I was blind and installed orca and brltty with every install
and by the time I had gotten rid of orca and brltty, it was not
rebootable without a full reinstall bdecause it waited forever for
orca to come online. I have finally managed to put a muffler on orca,
but for the last 2 years have been plagued by a 30 second system
lockup anytime something asks to run a gui-fied file selector. Or
other similar operations. I cannot use the best photo manager as it
won't wait for that timeout, shotwell does wait then handles my photo
work nicely, so I'm not totally crippled. gimp waits, runs fine after
the wait. And folks on the debian list where I've been a legendary
pain in the a$$ about this haven't a clue what might be wrong. If
trixie doesn't fix it, I'm off to xubuntu, after nearlly 20 years on
debian because LinuxCNC is built to run on debian, and I carve both
metal and wood with it on 4 CNC'd machines here, but then I'll have to
figure out how to run this stuff on ubuntu.

LinuxCNC has to have at a minimum of a preempt-rt kernel.

Not your problem, IRQ latency's under 50 u-secs, even on the rpi4b
that runs my 11x54 sheldon lathe, just background requirements here.

Thank you.

Cheers, Gene Heskett, CET.

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
On 6/26/25 09:32, gene heskett via Discuss wrote: > I have now unpacked yesterdays BOSL2-master.zip and removed the older > versions from /home/gene/.local/share/OpenSCAD/libraries, > > then copied the unpacked BOSL2-master.zip's contents to the above > libraries path as BOSL2, so all files there are now dated today. > > Then I re-arranged the file from the original post, and wrapped it as > a "module test();" > > So it now looks like this: > > module test(); {     include > </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>     > include > </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>     > difference()cylinder(h=50, d=16, $fn=150); > translate([0,0,1.5])cylinder(h=32.5, d=12); > translate([0,0,34])threaded_rod(d=12, l=16, pitch=2, internal=false, > bevel=0.5); } test(); And the formatting has been totally removed.  WTF????? > But I am still getting this error for an F5: > > Parsing design (AST generation)... > > Saved backup file: > /home/gene/.local/share/OpenSCAD/backups/unsaved-backup-aoYvNDoJ.scad > > ERROR: Parser error: syntax error in file > .local/share/OpenSCAD/libraries/BOSL2/color.scad, line 14 > > Execution aborted > > With the editor marking the > in red at the end of line 3. > > So obviously I am doing something wrong yet, but what? That is (I > think) a valid full path to the libraries. > > Problems like this have plagued every attempt I have made to use BOSL2 > for the years I've been trying to use bookworm (up to date a/o this > past Sunday) as my daily driver. This install is busted, and its > probably been reinstalled 30+ times because the original installer > thought I was blind and installed orca and brltty with every install > and by the time I had gotten rid of orca and brltty, it was not > rebootable without a full reinstall bdecause it waited forever for > orca to come online. I have finally managed to put a muffler on orca, > but for the last 2 years have been plagued by a 30 second system > lockup anytime something asks to run a gui-fied file selector. Or > other similar operations. I cannot use the best photo manager as it > won't wait for that timeout, shotwell does wait then handles my photo > work nicely, so I'm not totally crippled. gimp waits, runs fine after > the wait. And folks on the debian list where I've been a legendary > pain in the a$$ about this haven't a clue what might be wrong. If > trixie doesn't fix it, I'm off to xubuntu, after nearlly 20 years on > debian because LinuxCNC is built to run on debian, and I carve both > metal and wood with it on 4 CNC'd machines here, but then I'll have to > figure out how to run this stuff on ubuntu. > > LinuxCNC has to have at a minimum of a preempt-rt kernel. > > Not your problem, IRQ latency's under 50 u-secs, even on the rpi4b > that runs my 11x54 sheldon lathe, just background requirements here. > > Thank you. > > Cheers, Gene Heskett, CET. 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
GH
gene heskett
Thu, Jun 26, 2025 4:37 PM

On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote:

Gene,

Try moving the include statements above (outside) of the module definition.

Len

That worked, thank you. Is this a required rule?

But I had to modify both the z offset, and the length of the
threaded_rod by quite a bit to get it to project from the cylinder at
both ends, so that line now looks like this:

    #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2,
internal=false, bevel=0.5);

And I don't believe I see any bevel.

Threading is limited to the top by the 2nd cylinder and a bit of Z
tweaking made it clean to the bottom of the hole.

I see now that the line above this one clears the bore below the threads
so the added length of threaded_rod is not needed. The correct Z
translation would work as the OP seems to have a good understanding of
but using exactly the same for both subtractions was part of he error.

So my version with the stretched rod looks like this:

include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>
include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
module test();
{
    difference()
    {
        cylinder(h=50, d=16, $fn=150);
        translate([0,0,0])cylinder(h=32.5, d=12);
        translate([0,0,25])threaded_rod(d=12, l=55, pitch=2,
internal=false, bevel=0.5);
    }
}
test();

I hope this helps, it sure has me.

[...]

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
On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote: > Gene, > > Try moving the include statements above (outside) of the module definition. > > Len That worked, thank you. Is this a required rule? But I had to modify both the z offset, and the length of the threaded_rod by quite a bit to get it to project from the cylinder at both ends, so that line now looks like this:     #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2, internal=false, bevel=0.5); And I don't believe I see any bevel. Threading is limited to the top by the 2nd cylinder and a bit of Z tweaking made it clean to the bottom of the hole. I see now that the line above this one clears the bore below the threads so the added length of threaded_rod is not needed. The correct Z translation would work as the OP seems to have a good understanding of but using exactly the same for both subtractions was part of he error. So my version with the stretched rod looks like this: include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> module test(); {     difference()     {         cylinder(h=50, d=16, $fn=150);         translate([0,0,0])cylinder(h=32.5, d=12);         translate([0,0,25])threaded_rod(d=12, l=55, pitch=2, internal=false, bevel=0.5);     } } test(); I hope this helps, it sure has me. [...] >> 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
LM
Leonard Martin Struttmann
Thu, Jun 26, 2025 4:58 PM

That worked, thank you. Is this a required rule?

In this case, yes.  The OpenSCAD docs say "use <filename> is allowed only
at the top level of a file."

...and BOLS2 color.scad contains a use statement:

color.scad:use <builtins.scad>

On Thu, Jun 26, 2025 at 11:38 AM gene heskett via Discuss <
discuss@lists.openscad.org> wrote:

On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote:

Gene,

Try moving the include statements above (outside) of the module

definition.

Len

That worked, thank you. Is this a required rule?

But I had to modify both the z offset, and the length of the
threaded_rod by quite a bit to get it to project from the cylinder at
both ends, so that line now looks like this:

  #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2,

internal=false, bevel=0.5);

And I don't believe I see any bevel.

Threading is limited to the top by the 2nd cylinder and a bit of Z
tweaking made it clean to the bottom of the hole.

I see now that the line above this one clears the bore below the threads
so the added length of threaded_rod is not needed. The correct Z
translation would work as the OP seems to have a good understanding of
but using exactly the same for both subtractions was part of he error.

So my version with the stretched rod looks like this:

include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>
include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
module test();
{
difference()
{
cylinder(h=50, d=16, $fn=150);
translate([0,0,0])cylinder(h=32.5, d=12);
translate([0,0,25])threaded_rod(d=12, l=55, pitch=2,
internal=false, bevel=0.5);
}
}
test();

I hope this helps, it sure has me.

[...]

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

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

*That worked, thank you. Is this a required rule?* In this case, yes. The OpenSCAD docs say "use <*filename*> is allowed only at the top level of a file." ...and BOLS2 color.scad contains a use statement: color.scad:use <builtins.scad> On Thu, Jun 26, 2025 at 11:38 AM gene heskett via Discuss < discuss@lists.openscad.org> wrote: > On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote: > > Gene, > > > > Try moving the include statements above (outside) of the module > definition. > > > > Len > > That worked, thank you. Is this a required rule? > > But I had to modify both the z offset, and the length of the > threaded_rod by quite a bit to get it to project from the cylinder at > both ends, so that line now looks like this: > > #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2, > internal=false, bevel=0.5); > > And I don't believe I see any bevel. > > Threading is limited to the top by the 2nd cylinder and a bit of Z > tweaking made it clean to the bottom of the hole. > > I see now that the line above this one clears the bore below the threads > so the added length of threaded_rod is not needed. The correct Z > translation would work as the OP seems to have a good understanding of > but using exactly the same for both subtractions was part of he error. > > So my version with the stretched rod looks like this: > > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> > module test(); > { > difference() > { > cylinder(h=50, d=16, $fn=150); > translate([0,0,0])cylinder(h=32.5, d=12); > translate([0,0,25])threaded_rod(d=12, l=55, pitch=2, > internal=false, bevel=0.5); > } > } > test(); > > I hope this helps, it sure has me. > > [...] > > >> 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 > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jordan Brown
Thu, Jun 26, 2025 5:10 PM

On 6/26/2025 9:37 AM, gene heskett via Discuss wrote:

On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote:

Try moving the include statements above (outside) of the module
definition.

That worked, thank you. Is this a required rule?

Mostly, yes.

The include directive copies the specified file into your program,
almost exactly as if you replaced the include with the text of the
file.  (There's a little bit of magic to allow overriding variables in
the same scope.)

Usually, you want a library to be at the top level.  Some constructs may
require it - in this case, a "use" that BOSL2 uses internally.

That's not the only problem.

Here's your original text.  I've reformatted it for readability, but
changed only the whitespace, not anything that actually changes the
semantics.

module test();
{
    include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>
    include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
    difference()
        cylinder(h=50, d=16, $fn=150);
    translate([0,0,1.5])
        cylinder(h=32.5, d=12);
    translate([0,0,34])
        threaded_rod(d=12, l=16, pitch=2, internal=false, bevel=0.5);
}
test();

Reformatting like this makes a couple of things more obvious.

First is the semicolon after "module test()".  That makes the module be
empty.  The stuff in braces is some non-module stuff that's in what the
manual calls an "anonymous scope" which mostly isn't a scope at all.  An
anonymous scope mostly isn't a scope at all, but it's enough to make
"use" fail.

Second is that the difference() has only one child, so is kind of
boring.  I think it wants an open brace immediately after "difference()"
and a close brace after the call to threaded_rod().

So, going back to your original question, yes, libraries usually want
"include" or "use" at the top level.

There may be special cases where "include" might be useful at other points.

For instance, if you have a file that has a bunch of numbers separated
by commas, you could put it in an OpenSCAD array like so:

array = [
include <datafile.txt>
];

(Note:  this will not process general CSV.  The file must be valid
OpenSCAD syntax, which means commas between the elements, quotes around
strings, and so on.)

But these special cases are very much the exception.

For super extra fun, try this program.  Hint:  don't use "include" as a
variable name.

include = 2;
something = 5;
if (include < 3 && something > 4) {
    echo("surprise!");
}
On 6/26/2025 9:37 AM, gene heskett via Discuss wrote: > On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote: >> Try moving the include statements above (outside) of the module >> definition. > That worked, thank you. Is this a required rule? Mostly, yes. The include directive copies the specified file into your program, almost exactly as if you replaced the include with the text of the file.  (There's a little bit of magic to allow overriding variables in the same scope.) Usually, you want a library to be at the top level.  Some constructs may require it - in this case, a "use" that BOSL2 uses internally. That's not the only problem. Here's your original text.  I've reformatted it for readability, but changed only the whitespace, not anything that actually changes the semantics. module test(); { include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> difference() cylinder(h=50, d=16, $fn=150); translate([0,0,1.5]) cylinder(h=32.5, d=12); translate([0,0,34]) threaded_rod(d=12, l=16, pitch=2, internal=false, bevel=0.5); } test(); Reformatting like this makes a couple of things more obvious. First is the semicolon after "module test()".  That makes the module be empty.  The stuff in braces is some non-module stuff that's in what the manual calls an "anonymous scope" which mostly isn't a scope at all.  An anonymous scope mostly isn't a scope at all, but it's enough to make "use" fail. Second is that the difference() has only one child, so is kind of boring.  I think it wants an open brace immediately after "difference()" and a close brace after the call to threaded_rod(). So, going back to your original question, yes, libraries usually want "include" or "use" at the top level. There may be special cases where "include" might be useful at other points. For instance, if you have a file that has a bunch of numbers separated by commas, you could put it in an OpenSCAD array like so: array = [ include <datafile.txt> ]; (Note:  this will *not* process general CSV.  The file must be valid OpenSCAD syntax, which means commas between the elements, quotes around strings, and so on.) But these special cases are very much the exception. For super extra fun, try this program.  Hint:  don't use "include" as a variable name. include = 2; something = 5; if (include < 3 && something > 4) { echo("surprise!"); }
HW
Harvey white
Thu, Jun 26, 2025 7:02 PM

The include provides definitions.  By putting the include inside the
functions that were included, the call to the functions doesn't know
where to find what to call.  Putting the include outside provides the
definitions of where to find the stuff you call.  All programming
languages (IIRC) need this kind of order.  Define it first, then call it.

Compilers hate surprises.

Harvey

On 6/26/2025 12:37 PM, gene heskett via Discuss wrote:

On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote:

Gene,

Try moving the include statements above (outside) of the module
definition.

Len

That worked, thank you. Is this a required rule?

But I had to modify both the z offset, and the length of the
threaded_rod by quite a bit to get it to project from the cylinder at
both ends, so that line now looks like this:

    #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2,
internal=false, bevel=0.5);

And I don't believe I see any bevel.

Threading is limited to the top by the 2nd cylinder and a bit of Z
tweaking made it clean to the bottom of the hole.

I see now that the line above this one clears the bore below the
threads so the added length of threaded_rod is not needed. The correct
Z translation would work as the OP seems to have a good understanding
of but using exactly the same for both subtractions was part of he error.

So my version with the stretched rod looks like this:

include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>
include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
module test();
{
    difference()
    {
        cylinder(h=50, d=16, $fn=150);
        translate([0,0,0])cylinder(h=32.5, d=12);
        translate([0,0,25])threaded_rod(d=12, l=55, pitch=2,
internal=false, bevel=0.5);
    }
}
test();

I hope this helps, it sure has me.

[...]

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

Cheers, Gene Heskett, CET.

The include provides definitions.  By putting the include *inside* the functions that were included, the call to the functions doesn't know where to find what to call.  Putting the include *outside* provides the definitions of where to find the stuff you call.  All programming languages (IIRC) need this kind of order.  Define it first, then call it. Compilers hate surprises. Harvey On 6/26/2025 12:37 PM, gene heskett via Discuss wrote: > On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote: >> Gene, >> >> Try moving the include statements above (outside) of the module >> definition. >> >> Len > > That worked, thank you. Is this a required rule? > > But I had to modify both the z offset, and the length of the > threaded_rod by quite a bit to get it to project from the cylinder at > both ends, so that line now looks like this: > >     #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2, > internal=false, bevel=0.5); > > And I don't believe I see any bevel. > > Threading is limited to the top by the 2nd cylinder and a bit of Z > tweaking made it clean to the bottom of the hole. > > I see now that the line above this one clears the bore below the > threads so the added length of threaded_rod is not needed. The correct > Z translation would work as the OP seems to have a good understanding > of but using exactly the same for both subtractions was part of he error. > > So my version with the stretched rod looks like this: > > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> > module test(); > { >     difference() >     { >         cylinder(h=50, d=16, $fn=150); >         translate([0,0,0])cylinder(h=32.5, d=12); >         translate([0,0,25])threaded_rod(d=12, l=55, pitch=2, > internal=false, bevel=0.5); >     } > } > test(); > > I hope this helps, it sure has me. > > [...] > >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> > Cheers, Gene Heskett, CET.
L
larry
Thu, Jun 26, 2025 8:01 PM

On Thu, 2025-06-26 at 12:37 -0400, gene heskett via Discuss wrote:

On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote:

Gene,

Try moving the include statements above (outside) of the module definition.

Len

That worked, thank you. Is this a required rule?

But I had to modify both the z offset, and the length of the
threaded_rod by quite a bit to get it to project from the cylinder at
both ends, so that line now looks like this:

    #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2,
internal=false, bevel=0.5);

And I don't believe I see any bevel.

It's there, but it's a small bevel. Try changing it to 1.5 and put a
'#' at the beginning of that line. Of course, since the bevel is not
inside the cylinder, it will now be seen anywhere in the final render.

Threading is limited to the top by the 2nd cylinder and a bit of Z
tweaking made it clean to the bottom of the hole.

I see now that the line above this one clears the bore below the threads
so the added length of threaded_rod is not needed. The correct Z
translation would work as the OP seems to have a good understanding of
but using exactly the same for both subtractions was part of he error.

Right, but the cylinder which clears the bore needs to be smaller than
the bottom end of the threaded rod in order for the bevel to be in the
final render.

So my version with the stretched rod looks like this:

include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>
include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
module test();
{
    difference()
    {
        cylinder(h=50, d=16, $fn=150);
        translate([0,0,0])cylinder(h=32.5, d=12);
        translate([0,0,25])threaded_rod(d=12, l=55, pitch=2,
internal=false, bevel=0.5);
    }
}
test();

I hope this helps, it sure has me.

[...]

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

Cheers, Gene Heskett, CET.

On Thu, 2025-06-26 at 12:37 -0400, gene heskett via Discuss wrote: > On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote: > > Gene, > > > > Try moving the include statements above (outside) of the module definition. > > > > Len > > That worked, thank you. Is this a required rule? > > But I had to modify both the z offset, and the length of the > threaded_rod by quite a bit to get it to project from the cylinder at > both ends, so that line now looks like this: > >     #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2, > internal=false, bevel=0.5); > > And I don't believe I see any bevel. It's there, but it's a small bevel. Try changing it to 1.5 and put a '#' at the beginning of that line. Of course, since the bevel is not inside the cylinder, it will now be seen anywhere in the final render. > Threading is limited to the top by the 2nd cylinder and a bit of Z > tweaking made it clean to the bottom of the hole. > > I see now that the line above this one clears the bore below the threads > so the added length of threaded_rod is not needed. The correct Z > translation would work as the OP seems to have a good understanding of > but using exactly the same for both subtractions was part of he error. Right, but the cylinder which clears the bore needs to be smaller than the bottom end of the threaded rod in order for the bevel to be in the final render. > So my version with the stretched rod looks like this: > > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> > module test(); > { >     difference() >     { >         cylinder(h=50, d=16, $fn=150); >         translate([0,0,0])cylinder(h=32.5, d=12); >         translate([0,0,25])threaded_rod(d=12, l=55, pitch=2, > internal=false, bevel=0.5); >     } > } > test(); > > I hope this helps, it sure has me. > > [...] > > > > OpenSCAD mailing list > > > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > Cheers, Gene Heskett, CET.
AM
Adrian Mariano
Thu, Jun 26, 2025 8:26 PM

Because interior=false, the bevel is the wrong direction.  If you take a
rod and bevel the ends and then subtract that you're going to get a hole
with a little lip at the top.  You need to set inside=true, which reverses
the bevels.  Or you need to set a negative bevel so that it flares outward
so that it bevels the hole.

You can always try making the bevel really big, like how about 4.  You
wouldn't want such a big bevel, but you'll be able to see it!  A bevel on
a threaded rod can be subtle.

Really the threads will come out better if you use the interior argument
correctly.  In fact, I think with interior=false they won't work unless you
run the threads all the way off the end.

[image: image.png]

include<BOSL2/std.scad>
include<BOSL2/threading.scad>

threaded_rod(d=12, pitch=2, internal=true, l=25, bevel=2);
right(20)threaded_rod(d=12, pitch=2, internal=false, l=25, bevel=2);

On Thu, Jun 26, 2025 at 4:02 PM larry via Discuss <
discuss@lists.openscad.org> wrote:

On Thu, 2025-06-26 at 12:37 -0400, gene heskett via Discuss wrote:

On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote:

Gene,

Try moving the include statements above (outside) of the module

definition.

Len

That worked, thank you. Is this a required rule?

But I had to modify both the z offset, and the length of the
threaded_rod by quite a bit to get it to project from the cylinder at
both ends, so that line now looks like this:

  #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2,

internal=false, bevel=0.5);

And I don't believe I see any bevel.

It's there, but it's a small bevel. Try changing it to 1.5 and put a
'#' at the beginning of that line. Of course, since the bevel is not
inside the cylinder, it will now be seen anywhere in the final render.

Threading is limited to the top by the 2nd cylinder and a bit of Z
tweaking made it clean to the bottom of the hole.

I see now that the line above this one clears the bore below the threads
so the added length of threaded_rod is not needed. The correct Z
translation would work as the OP seems to have a good understanding of
but using exactly the same for both subtractions was part of he error.

Right, but the cylinder which clears the bore needs to be smaller than
the bottom end of the threaded rod in order for the bevel to be in the
final render.

So my version with the stretched rod looks like this:

include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>
include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
module test();
{
difference()
{
cylinder(h=50, d=16, $fn=150);
translate([0,0,0])cylinder(h=32.5, d=12);
translate([0,0,25])threaded_rod(d=12, l=55, pitch=2,
internal=false, bevel=0.5);
}
}
test();

I hope this helps, it sure has me.

[...]

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

Cheers, Gene Heskett, CET.


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

Because interior=false, the bevel is the wrong direction. If you take a rod and bevel the ends and then subtract that you're going to get a hole with a little lip at the top. You need to set inside=true, which reverses the bevels. Or you need to set a negative bevel so that it flares outward so that it bevels the hole. You can always try making the bevel really big, like how about 4. You wouldn't want such a big bevel, but you'll be able to see it! A bevel on a threaded rod can be subtle. Really the threads will come out better if you use the interior argument correctly. In fact, I think with interior=false they won't work unless you run the threads all the way off the end. [image: image.png] include<BOSL2/std.scad> include<BOSL2/threading.scad> threaded_rod(d=12, pitch=2, internal=true, l=25, bevel=2); right(20)threaded_rod(d=12, pitch=2, internal=false, l=25, bevel=2); On Thu, Jun 26, 2025 at 4:02 PM larry via Discuss < discuss@lists.openscad.org> wrote: > On Thu, 2025-06-26 at 12:37 -0400, gene heskett via Discuss wrote: > > On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote: > > > Gene, > > > > > > Try moving the include statements above (outside) of the module > definition. > > > > > > Len > > > > That worked, thank you. Is this a required rule? > > > > But I had to modify both the z offset, and the length of the > > threaded_rod by quite a bit to get it to project from the cylinder at > > both ends, so that line now looks like this: > > > > #translate([0,0,25])threaded_rod(d=12, l=51, pitch=2, > > internal=false, bevel=0.5); > > > > And I don't believe I see any bevel. > > It's there, but it's a small bevel. Try changing it to 1.5 and put a > '#' at the beginning of that line. Of course, since the bevel is not > inside the cylinder, it will now be seen anywhere in the final render. > > > > > Threading is limited to the top by the 2nd cylinder and a bit of Z > > tweaking made it clean to the bottom of the hole. > > > > I see now that the line above this one clears the bore below the threads > > so the added length of threaded_rod is not needed. The correct Z > > translation would work as the OP seems to have a good understanding of > > but using exactly the same for both subtractions was part of he error. > > Right, but the cylinder which clears the bore needs to be smaller than > the bottom end of the threaded rod in order for the bevel to be in the > final render. > > > So my version with the stretched rod looks like this: > > > > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> > > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> > > module test(); > > { > > difference() > > { > > cylinder(h=50, d=16, $fn=150); > > translate([0,0,0])cylinder(h=32.5, d=12); > > translate([0,0,25])threaded_rod(d=12, l=55, pitch=2, > > internal=false, bevel=0.5); > > } > > } > > test(); > > > > I hope this helps, it sure has me. > > > > [...] > > > > > > OpenSCAD mailing list > > > > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > > > Cheers, Gene Heskett, CET. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
L
larry
Thu, Jun 26, 2025 8:32 PM

On Thu, 2025-06-26 at 12:37 -0400, gene heskett via Discuss wrote:

So my version with the stretched rod looks like this:
include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>
include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
module test();
{
    difference()
    {
        cylinder(h=50, d=16, $fn=150);
        translate([0,0,0])cylinder(h=32.5, d=12);
        translate([0,0,25])threaded_rod(d=12, l=55, pitch=2,
internal=false, bevel=0.5);
    }
}
test();

Some comments:

include <BOSL2/std.scad>
include <BOSL2/threading.scad>
$fn= $preview ? 60 : 180; // automatic preview/render for $fn

// no semicolon after test()
module test() {
difference() {
cylinder(h=50, d=16, $fn=150);
// d=10 to allow for bevel
cylinder(h=32.5, d=10);
up(25+32.5) threaded_rod(d=12, l=50, pitch=2, internal=false,
bevel=1);

// uncomment the following line to see what's happening internally.
// cube(60);
}
}

test();

On Thu, 2025-06-26 at 12:37 -0400, gene heskett via Discuss wrote: > > So my version with the stretched rod looks like this: > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> > module test(); > { >     difference() >     { >         cylinder(h=50, d=16, $fn=150); >         translate([0,0,0])cylinder(h=32.5, d=12); >         translate([0,0,25])threaded_rod(d=12, l=55, pitch=2, > internal=false, bevel=0.5); >     } > } > test(); Some comments: include <BOSL2/std.scad> include <BOSL2/threading.scad> $fn= $preview ? 60 : 180; // automatic preview/render for $fn // no semicolon after test() module test() { difference() { cylinder(h=50, d=16, $fn=150); // d=10 to allow for bevel cylinder(h=32.5, d=10); up(25+32.5) threaded_rod(d=12, l=50, pitch=2, internal=false, bevel=1); // uncomment the following line to see what's happening internally. // cube(60); } } test();
GH
gene heskett
Thu, Jun 26, 2025 9:23 PM

On 6/26/25 12:58, Leonard Martin Struttmann via Discuss wrote:

That worked, thank you. Is this a required rule?

In this case, yes.  The OpenSCAD docs say "use <filename> is allowed only
at the top level of a file."

So is "include" an alias for "use"?  It seems to act like it is. except
"use" is a show stopper error

...and BOLS2 color.scad contains a use statement:

color.scad:use <builtins.scad>

Which assumes the default library path is correct. So my use of the full
path should not be required?

It apparently is good, removing the full path still works.  Thank you.

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
On 6/26/25 12:58, Leonard Martin Struttmann via Discuss wrote: > *That worked, thank you. Is this a required rule?* > > > In this case, yes. The OpenSCAD docs say "use <*filename*> is allowed only > at the top level of a file." So is "include" an alias for "use"?  It seems to act like it is. except "use" is a show stopper error > ...and BOLS2 color.scad contains a use statement: > > > color.scad:use <builtins.scad> Which assumes the default library path is correct. So my use of the full path should not be required? It apparently is good, removing the full path still works.  Thank you. > 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
AM
Adrian Mariano
Thu, Jun 26, 2025 9:40 PM

The "use" and "include" statements are different.  The intention of "use"
is to import a library while somewhat encapsulating it from the rest of the
code.  You're supposed to be able to run the file stand-alone to generate
examples, or run use it as a library.  Unfortunately, due to a bug in
OpenSCAD, if you use "use" then anytime you call a function in the used
file it runs every command that appears at the top level in the file.  This
was making some things in BOSL2 1000x slower, so we abandoned "use". The
"include" statement just directly includes the contents of the file, as if
they appeared right there in the code.

On Thu, Jun 26, 2025 at 5:23 PM gene heskett via Discuss <
discuss@lists.openscad.org> wrote:

On 6/26/25 12:58, Leonard Martin Struttmann via Discuss wrote:

That worked, thank you. Is this a required rule?

In this case, yes.  The OpenSCAD docs say "use <filename> is allowed

only

at the top level of a file."

So is "include" an alias for "use"?  It seems to act like it is. except
"use" is a show stopper error

...and BOLS2 color.scad contains a use statement:

color.scad:use <builtins.scad>

Which assumes the default library path is correct. So my use of the full
path should not be required?

It apparently is good, removing the full path still works.  Thank you.

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

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

The "use" and "include" statements are different. The intention of "use" is to import a library while somewhat encapsulating it from the rest of the code. You're supposed to be able to run the file stand-alone to generate examples, or run use it as a library. Unfortunately, due to a bug in OpenSCAD, if you use "use" then anytime you call a function in the used file it runs every command that appears at the top level in the file. This was making some things in BOSL2 1000x slower, so we abandoned "use". The "include" statement just directly includes the contents of the file, as if they appeared right there in the code. On Thu, Jun 26, 2025 at 5:23 PM gene heskett via Discuss < discuss@lists.openscad.org> wrote: > On 6/26/25 12:58, Leonard Martin Struttmann via Discuss wrote: > > *That worked, thank you. Is this a required rule?* > > > > > > In this case, yes. The OpenSCAD docs say "use <*filename*> is allowed > only > > at the top level of a file." > So is "include" an alias for "use"? It seems to act like it is. except > "use" is a show stopper error > > ...and BOLS2 color.scad contains a use statement: > > > > > > color.scad:use <builtins.scad> > > Which assumes the default library path is correct. So my use of the full > path should not be required? > > It apparently is good, removing the full path still works. Thank you. > > > 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 > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
GH
gene heskett
Thu, Jun 26, 2025 10:13 PM

On 6/26/25 13:11, Jordan Brown via Discuss wrote:

On 6/26/2025 9:37 AM, gene heskett via Discuss wrote:

On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote:

Try moving the include statements above (outside) of the module
definition.

That worked, thank you. Is this a required rule?

Mostly, yes.

The include directive copies the specified file into your program,
almost exactly as if you replaced the include with the text of the
file.  (There's a little bit of magic to allow overriding variables in
the same scope.)

Usually, you want a library to be at the top level.  Some constructs may
require it - in this case, a "use" that BOSL2 uses internally.

That's not the only problem.

Here's your original text.  I've reformatted it for readability, but
changed only the whitespace, not anything that actually changes the
semantics.

  module test() //fixed, still works
  {
      include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad>
      include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad>
      difference() {
          cylinder(h=50, d=16, $fn=150);
      translate([0,0,1.5])
          cylinder(h=32.5, d=12);
      translate([0,0,34])
          threaded_rod(d=12, l=16, pitch=2, internal=false, bevel=0.5); }
  }
  test();

Reformatting like this makes a couple of things more obvious.

First is the semicolon after "module test()".  That makes the module be
empty.  The stuff in braces is some non-module stuff that's in what the
manual calls an "anonymous scope" which mostly isn't a scope at all.  An
anonymous scope mostly isn't a scope at all, but it's enough to make
"use" fail.

Second is that the difference() has only one child,

Actually two, first expands to clear the threads at the bottom of the
central hole,

And the second is the threaded_rod threading the top of the hole.

so is kind of
boring.  I think it wants an open brace immediately after "difference()"
and a close brace after the call to threaded_rod().

done.

This likely would not print well because there is no visible
compensation for the expansion caused by the size of the nozzle,
typically .4mm.

In my personal use where I am fitting a 2 start plastic printed nut pair
of halves, so I reduce the image of the maple screw that started as a
27" 2x2 that is just short of 48mm in diameter once carved on my 6040 4
axis mill, I use the same bolt code made nominally .25mm small to
preview the bolt, and make the same bolt code when used as the
difference to make the nuts, is made .25mm bigger when making the nuts.
So the assembly has about .1mm backlash yet turns freely when the screw
is painted with pure carnaba wax. With about 13 teeth engaged, that
maple screw might as well be 4340 steel. A buttress thread is only 4mm
tall, and the pitch is 12mm per turn of the vice handle. So if I were to
make this, and assuming a commercially available bolt of nominally 12mm
diameter, I would measure its actual OD and expand the clearance
cylinder in the bottom by .5mm, and the diameter of the bolt by .45mm to
assure adequate clearance.  Assuming of course that the printer is well
calibrated. This sort of thinking will get a usable part for the OP at
least 1 iteration quicker.

So, going back to your original question, yes, libraries usually want
"include" or "use" at the top level.

"use" does not work here.

There may be special cases where "include" might be useful at other points.

For instance, if you have a file that has a bunch of numbers separated
by commas, you could put it in an OpenSCAD array like so:

  array = [
  include <datafile.txt>
  ];

(Note:  this will not process general CSV.  The file must be valid
OpenSCAD syntax, which means commas between the elements, quotes around
strings, and so on.)

But these special cases are very much the exception.

For super extra fun, try this program.  Hint:  don't use "include" as a
variable name.

  include = 2;
  something = 5;
  if (include < 3 && something > 4) {
      echo("surprise!");
  }

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

Thank you.

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
On 6/26/25 13:11, Jordan Brown via Discuss wrote: > On 6/26/2025 9:37 AM, gene heskett via Discuss wrote: >> On 6/26/25 11:04, Leonard Martin Struttmann via Discuss wrote: >>> Try moving the include statements above (outside) of the module >>> definition. >> That worked, thank you. Is this a required rule? > Mostly, yes. > > The include directive copies the specified file into your program, > almost exactly as if you replaced the include with the text of the > file.  (There's a little bit of magic to allow overriding variables in > the same scope.) > > Usually, you want a library to be at the top level.  Some constructs may > require it - in this case, a "use" that BOSL2 uses internally. > > That's not the only problem. > > Here's your original text.  I've reformatted it for readability, but > changed only the whitespace, not anything that actually changes the > semantics. > > module test() //fixed, still works > { > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/std.scad> > include </home/gene/.local/share/OpenSCAD/libraries/BOSL2/threading.scad> > difference() { > cylinder(h=50, d=16, $fn=150); > translate([0,0,1.5]) > cylinder(h=32.5, d=12); > translate([0,0,34]) > threaded_rod(d=12, l=16, pitch=2, internal=false, bevel=0.5); } > } > test(); > > Reformatting like this makes a couple of things more obvious. > > First is the semicolon after "module test()".  That makes the module be > empty.  The stuff in braces is some non-module stuff that's in what the > manual calls an "anonymous scope" which mostly isn't a scope at all.  An > anonymous scope mostly isn't a scope at all, but it's enough to make > "use" fail. > > Second is that the difference() has only one child, Actually two, first expands to clear the threads at the bottom of the central hole, And the second is the threaded_rod threading the top of the hole. > so is kind of > boring.  I think it wants an open brace immediately after "difference()" > and a close brace after the call to threaded_rod(). done. This likely would not print well because there is no visible compensation for the expansion caused by the size of the nozzle, typically .4mm. In my personal use where I am fitting a 2 start plastic printed nut pair of halves, so I reduce the image of the maple screw that started as a 27" 2x2 that is just short of 48mm in diameter once carved on my 6040 4 axis mill, I use the same bolt code made nominally .25mm small to preview the bolt, and make the same bolt code when used as the difference to make the nuts, is made .25mm bigger when making the nuts. So the assembly has about .1mm backlash yet turns freely when the screw is painted with pure carnaba wax. With about 13 teeth engaged, that maple screw might as well be 4340 steel. A buttress thread is only 4mm tall, and the pitch is 12mm per turn of the vice handle. So if I were to make this, and assuming a commercially available bolt of nominally 12mm diameter, I would measure its actual OD and expand the clearance cylinder in the bottom by .5mm, and the diameter of the bolt by .45mm to assure adequate clearance.  Assuming of course that the printer is well calibrated. This sort of thinking will get a usable part for the OP at least 1 iteration quicker. > So, going back to your original question, yes, libraries usually want > "include" or "use" at the top level. "use" does not work here. > There may be special cases where "include" might be useful at other points. > > For instance, if you have a file that has a bunch of numbers separated > by commas, you could put it in an OpenSCAD array like so: > > array = [ > include <datafile.txt> > ]; > > (Note:  this will *not* process general CSV.  The file must be valid > OpenSCAD syntax, which means commas between the elements, quotes around > strings, and so on.) > > But these special cases are very much the exception. > > For super extra fun, try this program.  Hint:  don't use "include" as a > variable name. > > include = 2; > something = 5; > if (include < 3 && something > 4) { > echo("surprise!"); > } > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org Thank you. 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
Jordan Brown
Fri, Jun 27, 2025 5:24 PM

On 6/26/2025 3:13 PM, gene heskett via Discuss wrote:

Second is that the difference() has only one child,

Actually two,

Ah, I see that you fixed that in an iteration after the one I quoted. 
Sorry.

So, going back to your original question, yes, libraries usually want
"include" or "use" at the top level.

"use" does not work here.

Some libraries want to be "included", while others want to be "used". 
BOSL2 wants to be "included".

On 6/26/2025 3:13 PM, gene heskett via Discuss wrote: >> Second is that the difference() has only one child, > Actually two, > Ah, I see that you fixed that in an iteration after the one I quoted.  Sorry. >> So, going back to your original question, yes, libraries usually want >> "include" or "use" at the top level. > "use" does not work here. Some libraries want to be "included", while others want to be "used".  BOSL2 wants to be "included".
GH
gene heskett
Fri, Jun 27, 2025 6:58 PM

On 6/27/25 13:25, Jordan Brown via Discuss wrote:

On 6/26/2025 3:13 PM, gene heskett via Discuss wrote:

Second is that the difference() has only one child,

Actually two,

Ah, I see that you fixed that in an iteration after the one I quoted.
Sorry.

NP. While I was pointing out that the 2 subtraction children existed in
the OP's first post. That snippet did not constrain the scope of the
difference so I added a pair of {} to do so. Makes, in this case, no
difference in the final result as there is not anything that s/b
excluded from the difference beyond the scope of the difference.

So, going back to your original question, yes, libraries usually want
"include" or "use" at the top level.

"use" does not work here.

Some libraries want to be "included", while others want to be "used".
BOSL2 wants to be "included".

A difference I don't see defined. It may be, but my hardcopy printout is
now 4 years old. I suspect that today it would be a dozen+ pages longer. ;)

Thanks Jordan.

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
On 6/27/25 13:25, Jordan Brown via Discuss wrote: > On 6/26/2025 3:13 PM, gene heskett via Discuss wrote: >>> Second is that the difference() has only one child, >> Actually two, >> > Ah, I see that you fixed that in an iteration after the one I quoted. > Sorry. NP. While I was pointing out that the 2 subtraction children existed in the OP's first post. That snippet did not constrain the scope of the difference so I added a pair of {} to do so. Makes, in this case, no difference in the final result as there is not anything that s/b excluded from the difference beyond the scope of the difference. >>> So, going back to your original question, yes, libraries usually want >>> "include" or "use" at the top level. >> "use" does not work here. > Some libraries want to be "included", while others want to be "used". > BOSL2 wants to be "included". A difference I don't see defined. It may be, but my hardcopy printout is now 4 years old. I suspect that today it would be a dozen+ pages longer. ;) Thanks Jordan. > 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
Jordan Brown
Fri, Jun 27, 2025 8:13 PM

On 6/27/2025 11:58 AM, gene heskett via Discuss wrote:

Some libraries want to be "included", while others want to be "used".
BOSL2 wants to be "included".

A difference I don't see defined. It may be, but my hardcopy printout
is now 4 years old. I suspect that today it would be a dozen+ pages
longer. ;)

The difference between the two is documented at

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement

I don't immediately see anything in the BOSL2 documentation that
discusses the distinction, but the examples all use "include".

On 6/27/2025 11:58 AM, gene heskett via Discuss wrote: >> Some libraries want to be "included", while others want to be "used". >> BOSL2 wants to be "included". > A difference I don't see defined. It may be, but my hardcopy printout > is now 4 years old. I suspect that today it would be a dozen+ pages > longer. ;) The difference between the two is documented at https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement I don't immediately see anything in the BOSL2 documentation that discusses the distinction, but the examples all use "include".
FH
Father Horton
Fri, Jun 27, 2025 8:31 PM

I don't know why there should be a difference with BOSL2, but just for fun,
I opened an existing file that works fine, changed the "include" to "use",
and got errors.

On Fri, Jun 27, 2025 at 3:14 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

On 6/27/2025 11:58 AM, gene heskett via Discuss wrote:

Some libraries want to be "included", while others want to be "used".
BOSL2 wants to be "included".

A difference I don't see defined. It may be, but my hardcopy printout is
now 4 years old. I suspect that today it would be a dozen+ pages longer. ;)

The difference between the two is documented at

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement

I don't immediately see anything in the BOSL2 documentation that discusses
the distinction, but the examples all use "include".


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

I don't know why there should be a difference with BOSL2, but just for fun, I opened an existing file that works fine, changed the "include" to "use", and got errors. On Fri, Jun 27, 2025 at 3:14 PM Jordan Brown via Discuss < discuss@lists.openscad.org> wrote: > On 6/27/2025 11:58 AM, gene heskett via Discuss wrote: > > Some libraries want to be "included", while others want to be "used". > BOSL2 wants to be "included". > > A difference I don't see defined. It may be, but my hardcopy printout is > now 4 years old. I suspect that today it would be a dozen+ pages longer. ;) > > > The difference between the two is documented at > > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement > > > I don't immediately see anything in the BOSL2 documentation that discusses > the distinction, but the examples all use "include". > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AM
Adrian Mariano
Fri, Jun 27, 2025 9:12 PM

BOSL2 defines global variables at the top level that are then referenced by
other files than the one where they are defined.  This works with include
but does not work with use.

On Fri, Jun 27, 2025 at 4:32 PM Father Horton via Discuss <
discuss@lists.openscad.org> wrote:

I don't know why there should be a difference with BOSL2, but just for
fun, I opened an existing file that works fine, changed the "include" to
"use", and got errors.

On Fri, Jun 27, 2025 at 3:14 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

On 6/27/2025 11:58 AM, gene heskett via Discuss wrote:

Some libraries want to be "included", while others want to be "used".
BOSL2 wants to be "included".

A difference I don't see defined. It may be, but my hardcopy printout is
now 4 years old. I suspect that today it would be a dozen+ pages longer. ;)

The difference between the two is documented at

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement

I don't immediately see anything in the BOSL2 documentation that
discusses the distinction, but the examples all use "include".


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

BOSL2 defines global variables at the top level that are then referenced by other files than the one where they are defined. This works with include but does not work with use. On Fri, Jun 27, 2025 at 4:32 PM Father Horton via Discuss < discuss@lists.openscad.org> wrote: > I don't know why there should be a difference with BOSL2, but just for > fun, I opened an existing file that works fine, changed the "include" to > "use", and got errors. > > On Fri, Jun 27, 2025 at 3:14 PM Jordan Brown via Discuss < > discuss@lists.openscad.org> wrote: > >> On 6/27/2025 11:58 AM, gene heskett via Discuss wrote: >> >> Some libraries want to be "included", while others want to be "used". >> BOSL2 wants to be "included". >> >> A difference I don't see defined. It may be, but my hardcopy printout is >> now 4 years old. I suspect that today it would be a dozen+ pages longer. ;) >> >> >> The difference between the two is documented at >> >> https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Include_Statement >> >> >> I don't immediately see anything in the BOSL2 documentation that >> discusses the distinction, but the examples all use "include". >> >> _______________________________________________ >> 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 >
FH
Father Horton
Fri, Jun 27, 2025 11:15 PM

I guess that’s implicit in what it says, but an explicit statement that
global variable assignments don’t happen with a “use” would be handy.

I guess that’s implicit in what it says, but an explicit statement that global variable assignments don’t happen with a “use” would be handy.
AM
Adrian Mariano
Fri, Jun 27, 2025 11:23 PM

It seems like the text about "use" is fairly explicit, when it says that if
A uses B then neither A nor B can see global variables defined in the other
file.

It doesn't mean global variable assignments "don't happen" because if B
makes global variable assignments they do get run---in fact they get
(re)run every time you invoke a function defined in B.  But those global
definitions are only global to B, not global to the whole program.

On Fri, Jun 27, 2025 at 7:15 PM Father Horton via Discuss <
discuss@lists.openscad.org> wrote:

I guess that’s implicit in what it says, but an explicit statement that
global variable assignments don’t happen with a “use” would be handy.


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

It seems like the text about "use" is fairly explicit, when it says that if A uses B then neither A nor B can see global variables defined in the other file. It doesn't mean global variable assignments "don't happen" because if B makes global variable assignments they do get run---in fact they get (re)run every time you invoke a function defined in B. But those global definitions are only global to B, not global to the whole program. On Fri, Jun 27, 2025 at 7:15 PM Father Horton via Discuss < discuss@lists.openscad.org> wrote: > I guess that’s implicit in what it says, but an explicit statement that > global variable assignments don’t happen with a “use” would be handy. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >