K
Ken
Sun, May 25, 2025 1:37 PM
Thanks Torsten, excellent suggestion. After a bit of reading up on json syntax, I have my header more or less working.
One small problem I have is with the escaping of double quotes.
Below is how my header file now looks in openscad. The problem I cannot solve is on lines 4 and 8- one of triple backslashes needed to escape the double quotes is showing in the text. If I remove one of the backslashes, the json longer works.
I have attached the relevant json file- any suggestions to remove the extra slashes from the openscad display gratefully received.
1 include <BOSL2/std.scad>
2 include <BOSL2/threading.scad>
3 //Example of use of this module in a project
4 //Place "use <C:/ownCloud/openscad files/text_module.scad>"
5 //at the top of the project (without the quotes)
6 //Then in the appropriate place(s), place required height without quotes, then required text in quotes and the required font & style in quotes,
7 // then the size without quotes- eg.
8 //place_text(2,"VK7KRJ","Liberation Sans:style=Bold",6);
9 use <C:/ownCloud/openscad files/0 examples/text_module.scad>
10 use <C:/ownCloud/openscad files/0 examples/heatset hole modules/3mm heatset insert hole module.scad>
11 $fn = 128;
On 2025-05-25 10:10, Torsten Paul via Discuss wrote:
It's not fully automatic, but maybe a bit more flexible...
Create a "templates" subfolder in the configuration directory,
e.g. on Linux: $HOME/.config/OpenSCAD/templates
Into that folder, put a file, e.g. called header.json with the
following content (including the curly braces)
{
"key" : "MyHeader",
"content" : "// Hi There!\n// This is my very special template\n\n^~^"
}
Use ALT+Ins (no idea what that would be on macOS), or use
mouse right-click -> insert template. Select "MyHeader" in
the popup.
The "^~^" is the marker where to place the cursor.
ciao,
Torsten.
A baby can be defined as an ego with a noise at one end and a smell at the other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!
Thanks Torsten, excellent suggestion. After a bit of reading up on json syntax, I have my header more or less working.
One small problem I have is with the escaping of double quotes.
Below is how my header file now looks in openscad. The problem I cannot solve is on lines 4 and 8- one of triple backslashes needed to escape the double quotes is showing in the text. If I remove one of the backslashes, the json longer works.
I have attached the relevant json file- any suggestions to remove the extra slashes from the openscad display gratefully received.
1 include <BOSL2/std.scad>
2 include <BOSL2/threading.scad>
3 //Example of use of this module in a project
4 //Place \"use <C:/ownCloud/openscad files/text_module.scad>\"
5 //at the top of the project (without the quotes)
6 //Then in the appropriate place(s), place required height without quotes, then required text in quotes and the required font & style in quotes,
7 // then the size without quotes- eg.
8 //place_text(2,\"VK7KRJ\",\"Liberation Sans:style=Bold\",6);
9 use <C:/ownCloud/openscad files/0 examples/text_module.scad>
10 use <C:/ownCloud/openscad files/0 examples/heatset hole modules/3mm heatset insert hole module.scad>
11 $fn = 128;
On 2025-05-25 10:10, Torsten Paul via Discuss wrote:
> It's not fully automatic, but maybe a bit more flexible...
>
> Create a "templates" subfolder in the configuration directory,
> e.g. on Linux: $HOME/.config/OpenSCAD/templates
>
> Into that folder, put a file, e.g. called header.json with the
> following content (including the curly braces)
>
> {
> "key" : "MyHeader",
> "content" : "// Hi There!\n// This is my very special template\n\n^~^"
> }
>
> Use ALT+Ins (no idea what that would be on macOS), or use
> mouse right-click -> insert template. Select "MyHeader" in
> the popup.
>
> The "^~^" is the marker where to place the cursor.
>
> ciao,
> Torsten.
--
Cheers, Ken
bats059@gmail.com
https://vk7krj.com
https://vk7krj.com/running.html
----------------------------------------
A baby can be defined as an ego with a noise at one end and a smell at the other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!
JB
Jordan Brown
Sun, May 25, 2025 3:18 PM
You could also create your own mini library that does the setup that you like. Your library would look like
include <BOSL2/std.scad>
$fs = 1;
$fa = 1;
Put that in your OpenSCAD library folder (on Windows, Documents\OpenSCAD\libraries). Call it whatever.scad.
Then in your models say “include <whatever.scad>”.
The advantage and disadvantage over templates is that when you make a change to your common stuff, it applies to all of your existing models without needing to edit each one.
You could also create your own mini library that does the setup that you like. Your library would look like
include <BOSL2/std.scad>
$fs = 1;
$fa = 1;
Put that in your OpenSCAD library folder (on Windows, Documents\OpenSCAD\libraries). Call it whatever.scad.
Then in your models say “include <whatever.scad>”.
The advantage and disadvantage over templates is that when you make a change to your common stuff, it applies to all of your existing models without needing to edit each one.
AM
Adrian Mariano
Sun, May 25, 2025 3:46 PM
At least two people said the attachment tutorial didn't work for them. I
would say that if this is the case it absolutely is the tutorial's fault.
So if anybody has ideas on how to make the tutorial accessible to a broader
audience that might be useful.
On Fri, May 23, 2025 at 4:33 PM Father Horton via Discuss <
discuss@lists.openscad.org> wrote:
The two features I use most are the threading/screws functions and the
turtle graphics. Attachments sound useful, but the tutorial doesn't work
the way my mind does (not the tutorial's fault) and I can't get the hang of
how to use them.
On Fri, May 23, 2025 at 3:11 PM Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
I wrote a summary in which I tried to capture the capabilities provided
by the BOSL2 library, and we've had some discussion about the right order
to list them in. I'm interested in hearing from users of BOSL2, or even
people who are not (yet/) BOSL2 users but are interested in BOSL2, about
which features you think are the most useful or most important. How would
you order this list? Which features do you think are the least
interesting? Did I somehow not include on the list your favorite feature?
I encourage you to send your replies by direct email rather than to the
list unless you have something to say that you think is of broad interest.
- *Attachments.* Unless you make models containing just one object
the attachments features can revolutionize your modeling. They let you
position components of a model relative to other components so you don't
have to keep track of the positions and orientations of parts of the model.
You can instead place an something on the TOP of something else, perhaps
aligned to the RIGHT. For a full introduction to attachments, consult the Attachments
Tutorial.
<https://github.com/BelfrySCAD/BOSL2/wiki/Tutorial-Attachments>
- *Rounding and filleting.* Rounding and filleting is hard in
OpenSCAD. The library provides modules like cuboid()
<https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#module-cuboid>
to make a cube with any of the edges rounded, offset_sweep()
<https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-offset_sweep>
to round the ends of a linear extrusion, and prism_connector()
<https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#module-prism_connector>
which works with the attachments feature to create filleted prisms between
a variety of objects, or even rounded holes through a single object. You
can also use edge_profile()
<https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_profile>
to apply a variety of different mask profiles to chosen edges of a cubic
shape, or you can directly subtract 3d mask shapes from an edge of objects
that are not cubes.
- *Complex object support.* The path_sweep()
<https://github.com/BelfrySCAD/BOSL2/wiki/skin.scad#functionmodule-path_sweep>
function/module takes a 2d polygon moves it through space along a path and
sweeps out a 3d shape as it moves. You can link together a series of
arbitrary polygons with skin()
<https://github.com/BelfrySCAD/BOSL2/wiki/skin.scad#functionmodule-skin>
or vnf_vertex_array().
<https://github.com/BelfrySCAD/BOSL2/wiki/vnf.scad#functionmodule-vnf_vertex_array>
Support for beziers
<https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad> and NURBS
<https://github.com/BelfrySCAD/BOSL2/wiki/nurbs.scad> can help you
construct the building blocks you need. Metaballs
<https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad#functionmodule-metaballs>
can create organic surfaces that blend shapes together.
- *Building Blocks.* OpenSCAD provides cubes, cones and spheres. The
BOSL2 library extends this to provide different kinds of prisms, tubes, and
other abstract geometrical building blocks. In many cases the BOSL2 objects
include options to round their edges. Basic objects have extensions like
the ability to specify the *inner* radius of a circle to create holes
with a guaranteed minimum size.
- *Texturing.* Many kinds of objects can be created with textures
<https://github.com/BelfrySCAD/BOSL2/wiki/skin.scad#section-texturing>
applied. This can create knurling, but it can do much more than that. A
texture can be any repeating pattern, and applying a texture can actually
replace the base object with something different based on repeating copies
of the texture element. A texture can also be an image; using texturing you
can emboss an arbitrary image onto your model.
- *Parts library.* The parts library includes many useful specific
functional parts including gears
<https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad>, generic
threading
<https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#section-generic-threading>,
and specific threading to match plastic bottles
<https://github.com/BelfrySCAD/BOSL2/wiki/bottlecaps.scad>, pipe
fittings
<https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-npt_threaded_rod>,
or standard screws.
<https://github.com/BelfrySCAD/BOSL2/wiki/screws.scad> Also included
are clips
<https://github.com/BelfrySCAD/BOSL2/wiki/joiners.scad#section-tension-clips>,
hinges <https://github.com/BelfrySCAD/BOSL2/wiki/hinges.scad>, and dovetail
joints.
<https://github.com/BelfrySCAD/BOSL2/wiki/joiners.scad#section-dovetails>
- *Shorthands.* The shorthands make your code a little shorter, and
more importantly, they can make it significantly easier to read. Compare
up(x) to translate([0,0,x]). The shorthands include operations for
creating copies of objects
<https://github.com/BelfrySCAD/BOSL2/wiki/distributors.scad> and for
applying transformations
<https://github.com/BelfrySCAD/BOSL2/wiki/transforms.scad> to
objects, including rot()
<https://github.com/BelfrySCAD/BOSL2/wiki/transforms.scad#functionmodule-rot>
which extends rotate in some useful ways that are not easy to do directly.
- *Geometrical operations on data.* In OpenSCAD, geometrical
operations happen on geometry, and information can never be extracted from
geometry. The BOLS2 library provides operations on 2d point lists (called
"paths" or "regions") to make rounded paths
<https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#function-round_corners>
from ones with corners or do operations like intersection
<https://github.com/BelfrySCAD/BOSL2/wiki/regions.scad#functionmodule-intersection>
and offset
<https://github.com/BelfrySCAD/BOSL2/wiki/regions.scad#function-offset>.
It can also do some limited operations on three dimensional data.
- *Programming aids.* The library provides basic mathematical
operations <https://github.com/BelfrySCAD/BOSL2/wiki/math.scad>
including solutions to linear systems of equations
<https://github.com/BelfrySCAD/BOSL2/wiki/linalg.scad#function-linear_solve>
and generic
<https://github.com/BelfrySCAD/BOSL2/wiki/math.scad#function-root_find>
and polynomial
<https://github.com/BelfrySCAD/BOSL2/wiki/math.scad#function-real_roots>
numerical root finding. It provides geometrical operations
<https://github.com/BelfrySCAD/BOSL2/wiki/geometry.scad> like line
intersection
<https://github.com/BelfrySCAD/BOSL2/wiki/geometry.scad#function-line_intersection>
or circle intersection
<https://github.com/BelfrySCAD/BOSL2/wiki/geometry.scad#function-circle_circle_intersection>,
coordinate transformations
<https://github.com/BelfrySCAD/BOSL2/wiki/coords.scad>, string
manipulation, <https://github.com/BelfrySCAD/BOSL2/wiki/strings.scad>
and list processing
<https://github.com/BelfrySCAD/BOSL2/wiki/lists.scad>.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
At least two people said the attachment tutorial didn't work for them. I
would say that if this is the case it absolutely is the tutorial's fault.
So if anybody has ideas on how to make the tutorial accessible to a broader
audience that might be useful.
On Fri, May 23, 2025 at 4:33 PM Father Horton via Discuss <
discuss@lists.openscad.org> wrote:
> The two features I use most are the threading/screws functions and the
> turtle graphics. Attachments sound useful, but the tutorial doesn't work
> the way my mind does (not the tutorial's fault) and I can't get the hang of
> how to use them.
>
> On Fri, May 23, 2025 at 3:11 PM Adrian Mariano via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> I wrote a summary in which I tried to capture the capabilities provided
>> by the BOSL2 library, and we've had some discussion about the right order
>> to list them in. I'm interested in hearing from users of BOSL2, or even
>> people who are not (yet/) BOSL2 users but are interested in BOSL2, about
>> which features you think are the most useful or most important. How would
>> you order this list? Which features do you think are the least
>> interesting? Did I somehow not include on the list your favorite feature?
>> I encourage you to send your replies by direct email rather than to the
>> list unless you have something to say that you think is of broad interest.
>>
>> - *Attachments.* Unless you make models containing just one object
>> the attachments features can revolutionize your modeling. They let you
>> position components of a model relative to other components so you don't
>> have to keep track of the positions and orientations of parts of the model.
>> You can instead place an something on the TOP of something else, perhaps
>> aligned to the RIGHT. For a full introduction to attachments, consult the Attachments
>> Tutorial.
>> <https://github.com/BelfrySCAD/BOSL2/wiki/Tutorial-Attachments>
>> - *Rounding and filleting.* Rounding and filleting is hard in
>> OpenSCAD. The library provides modules like cuboid()
>> <https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#module-cuboid>
>> to make a cube with any of the edges rounded, offset_sweep()
>> <https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-offset_sweep>
>> to round the ends of a linear extrusion, and prism_connector()
>> <https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#module-prism_connector>
>> which works with the attachments feature to create filleted prisms between
>> a variety of objects, or even rounded holes through a single object. You
>> can also use edge_profile()
>> <https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_profile>
>> to apply a variety of different mask profiles to chosen edges of a cubic
>> shape, or you can directly subtract 3d mask shapes from an edge of objects
>> that are not cubes.
>> - *Complex object support.* The path_sweep()
>> <https://github.com/BelfrySCAD/BOSL2/wiki/skin.scad#functionmodule-path_sweep>
>> function/module takes a 2d polygon moves it through space along a path and
>> sweeps out a 3d shape as it moves. You can link together a series of
>> arbitrary polygons with skin()
>> <https://github.com/BelfrySCAD/BOSL2/wiki/skin.scad#functionmodule-skin>
>> or vnf_vertex_array().
>> <https://github.com/BelfrySCAD/BOSL2/wiki/vnf.scad#functionmodule-vnf_vertex_array>
>> Support for beziers
>> <https://github.com/BelfrySCAD/BOSL2/wiki/beziers.scad> and NURBS
>> <https://github.com/BelfrySCAD/BOSL2/wiki/nurbs.scad> can help you
>> construct the building blocks you need. Metaballs
>> <https://github.com/BelfrySCAD/BOSL2/wiki/isosurface.scad#functionmodule-metaballs>
>> can create organic surfaces that blend shapes together.
>> - *Building Blocks.* OpenSCAD provides cubes, cones and spheres. The
>> BOSL2 library extends this to provide different kinds of prisms, tubes, and
>> other abstract geometrical building blocks. In many cases the BOSL2 objects
>> include options to round their edges. Basic objects have extensions like
>> the ability to specify the *inner* radius of a circle to create holes
>> with a guaranteed minimum size.
>> - *Texturing.* Many kinds of objects can be created with textures
>> <https://github.com/BelfrySCAD/BOSL2/wiki/skin.scad#section-texturing>
>> applied. This can create knurling, but it can do much more than that. A
>> texture can be any repeating pattern, and applying a texture can actually
>> replace the base object with something different based on repeating copies
>> of the texture element. A texture can also be an image; using texturing you
>> can emboss an arbitrary image onto your model.
>> - *Parts library.* The parts library includes many useful specific
>> functional parts including gears
>> <https://github.com/BelfrySCAD/BOSL2/wiki/gears.scad>, generic
>> threading
>> <https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#section-generic-threading>,
>> and specific threading to match plastic bottles
>> <https://github.com/BelfrySCAD/BOSL2/wiki/bottlecaps.scad>, pipe
>> fittings
>> <https://github.com/BelfrySCAD/BOSL2/wiki/threading.scad#module-npt_threaded_rod>,
>> or standard screws.
>> <https://github.com/BelfrySCAD/BOSL2/wiki/screws.scad> Also included
>> are clips
>> <https://github.com/BelfrySCAD/BOSL2/wiki/joiners.scad#section-tension-clips>,
>> hinges <https://github.com/BelfrySCAD/BOSL2/wiki/hinges.scad>, and dovetail
>> joints.
>> <https://github.com/BelfrySCAD/BOSL2/wiki/joiners.scad#section-dovetails>
>> - *Shorthands.* The shorthands make your code a little shorter, and
>> more importantly, they can make it significantly easier to read. Compare
>> up(x) to translate([0,0,x]). The shorthands include operations for
>> creating copies of objects
>> <https://github.com/BelfrySCAD/BOSL2/wiki/distributors.scad> and for
>> applying transformations
>> <https://github.com/BelfrySCAD/BOSL2/wiki/transforms.scad> to
>> objects, including rot()
>> <https://github.com/BelfrySCAD/BOSL2/wiki/transforms.scad#functionmodule-rot>
>> which extends rotate in some useful ways that are not easy to do directly.
>> - *Geometrical operations on data.* In OpenSCAD, geometrical
>> operations happen on geometry, and information can never be extracted from
>> geometry. The BOLS2 library provides operations on 2d point lists (called
>> "paths" or "regions") to make rounded paths
>> <https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#function-round_corners>
>> from ones with corners or do operations like intersection
>> <https://github.com/BelfrySCAD/BOSL2/wiki/regions.scad#functionmodule-intersection>
>> and offset
>> <https://github.com/BelfrySCAD/BOSL2/wiki/regions.scad#function-offset>.
>> It can also do some limited operations on three dimensional data.
>> - *Programming aids.* The library provides basic mathematical
>> operations <https://github.com/BelfrySCAD/BOSL2/wiki/math.scad>
>> including solutions to linear systems of equations
>> <https://github.com/BelfrySCAD/BOSL2/wiki/linalg.scad#function-linear_solve>
>> and generic
>> <https://github.com/BelfrySCAD/BOSL2/wiki/math.scad#function-root_find>
>> and polynomial
>> <https://github.com/BelfrySCAD/BOSL2/wiki/math.scad#function-real_roots>
>> numerical root finding. It provides geometrical operations
>> <https://github.com/BelfrySCAD/BOSL2/wiki/geometry.scad> like line
>> intersection
>> <https://github.com/BelfrySCAD/BOSL2/wiki/geometry.scad#function-line_intersection>
>> or circle intersection
>> <https://github.com/BelfrySCAD/BOSL2/wiki/geometry.scad#function-circle_circle_intersection>,
>> coordinate transformations
>> <https://github.com/BelfrySCAD/BOSL2/wiki/coords.scad>, string
>> manipulation, <https://github.com/BelfrySCAD/BOSL2/wiki/strings.scad>
>> and list processing
>> <https://github.com/BelfrySCAD/BOSL2/wiki/lists.scad>.
>>
>>
>> _______________________________________________
>> 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
>
L
larry
Sun, May 25, 2025 4:06 PM
On Sun, 2025-05-25 at 02:10 +0200, Torsten Paul via Discuss wrote:
On 25.05.25 01:53, Jon Bondy via Discuss wrote:
I would love this! Maybe if a file called "header.inc" or "header.scad"
exists, then automatically put it at the top of the file.
It's not fully automatic, but maybe a bit more flexible...
Create a "templates" subfolder in the configuration directory,
e.g. on Linux: $HOME/.config/OpenSCAD/templates
Into that folder, put a file, e.g. called header.json with the
following content (including the curly braces)
{
"key" : "MyHeader",
"content" : "// Hi There!\n// This is my very special
template\n\n^~^"
}
Use ALT+Ins (no idea what that would be on macOS), or use
mouse right-click -> insert template. Select "MyHeader" in
the popup.
The "^~^" is the marker where to place the cursor.
I like it, but I do have some questions
When I use ALT+Ins, I get a list of (presumably) templates.
Where are they coming from? There are I'd like to delete, and two I'd
like to modify. If I put the ones I want to modify into the json file,
will it override the ones that are showing up now?
I haven't played with .json files at all. If I wanted to put another
template in the file, for example, 'module', how would I do that?
On Sun, 2025-05-25 at 02:10 +0200, Torsten Paul via Discuss wrote:
> On 25.05.25 01:53, Jon Bondy via Discuss wrote:
> > I would love this! Maybe if a file called "header.inc" or "header.scad"
> > exists, then automatically put it at the top of the file.
>
> It's not fully automatic, but maybe a bit more flexible...
>
> Create a "templates" subfolder in the configuration directory,
> e.g. on Linux: $HOME/.config/OpenSCAD/templates
>
> Into that folder, put a file, e.g. called header.json with the
> following content (including the curly braces)
>
> {
> "key" : "MyHeader",
> "content" : "// Hi There!\n// This is my very special
> template\n\n^~^"
> }
>
> Use ALT+Ins (no idea what that would be on macOS), or use
> mouse right-click -> insert template. Select "MyHeader" in
> the popup.
>
> The "^~^" is the marker where to place the cursor.
I like it, but I do have some questions
When I use ALT+Ins, I get a list of (presumably) templates.
Where are they coming from? There are I'd like to delete, and two I'd
like to modify. If I put the ones I want to modify into the json file,
will it override the ones that are showing up now?
I haven't played with .json files at all. If I wanted to put another
template in the file, for example, 'module', how would I do that?
TP
Torsten Paul
Sun, May 25, 2025 4:20 PM
On 25.05.25 18:06, larry via Discuss wrote:
When I use ALT+Ins, I get a list of (presumably) templates.
Where are they coming from?
Those are shipped with OpenSCAD. They are stored in a templates
folder inside the "Resource Path" (see Help->Library Info).
I haven't played with .json files at all. If I wanted to put another
template in the file, for example, 'module', how would I do that?
One file = one template.
ciao,
Torsten.
On 25.05.25 18:06, larry via Discuss wrote:
> When I use ALT+Ins, I get a list of (presumably) templates.
> Where are they coming from?
Those are shipped with OpenSCAD. They are stored in a templates
folder inside the "Resource Path" (see Help->Library Info).
> I haven't played with .json files at all. If I wanted to put another
> template in the file, for example, 'module', how would I do that?
One file = one template.
ciao,
Torsten.
GS
Guenther Sohler
Sun, May 25, 2025 5:31 PM
Another Option to have the favorite libraries always with you is this one:
Configure them in the preferebnces and they will automatically inserted in
every new Design you start with.
like this:
https://imgur.com/a/MfcygSc
This one works across computers and platforms, but you could also just put
directory paths inside.
On Sun, May 25, 2025 at 7:12 PM Ken via Discuss discuss@lists.openscad.org
wrote:
Thanks Torsten, excellent suggestion. After a bit of reading up on json
syntax, I have my header more or less working.
One small problem I have is with the escaping of double quotes.
Below is how my header file now looks in openscad. The problem I cannot
solve is on lines 4 and 8- one of triple backslashes needed to escape the
double quotes is showing in the text. If I remove one of the backslashes,
the json longer works.
I have attached the relevant json file- any suggestions to remove the
extra slashes from the openscad display gratefully received.
1 include <BOSL2/std.scad>
2 include <BOSL2/threading.scad>
3 //Example of use of this module in a project
4 //Place "use <C:/ownCloud/openscad files/text_module.scad>"
5 //at the top of the project (without the quotes)
6 //Then in the appropriate place(s), place required height without
quotes, then required text in quotes and the required font & style in
quotes,
7 // then the size without quotes- eg.
8 //place_text(2,"VK7KRJ","Liberation Sans:style=Bold",6);
9 use <C:/ownCloud/openscad files/0 examples/text_module.scad>
10 use <C:/ownCloud/openscad files/0 examples/heatset hole modules/3mm
heatset insert hole module.scad>
11 $fn = 128;
On 2025-05-25 10:10, Torsten Paul via Discuss wrote:
It's not fully automatic, but maybe a bit more flexible...
Create a "templates" subfolder in the configuration directory,
e.g. on Linux: $HOME/.config/OpenSCAD/templates
Into that folder, put a file, e.g. called header.json with the
following content (including the curly braces)
{
"key" : "MyHeader",
"content" : "// Hi There!\n// This is my very special
}
Use ALT+Ins (no idea what that would be on macOS), or use
mouse right-click -> insert template. Select "MyHeader" in
the popup.
The "^~^" is the marker where to place the cursor.
ciao,
Torsten.
A baby can be defined as an ego with a noise at one end and a smell at the
other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Another Option to have the favorite libraries always with you is this one:
Configure them in the preferebnces and they will automatically inserted in
every new Design you start with.
like this:
https://imgur.com/a/MfcygSc
This one works across computers and platforms, but you could also just put
directory paths inside.
On Sun, May 25, 2025 at 7:12 PM Ken via Discuss <discuss@lists.openscad.org>
wrote:
> Thanks Torsten, excellent suggestion. After a bit of reading up on json
> syntax, I have my header more or less working.
> One small problem I have is with the escaping of double quotes.
>
> Below is how my header file now looks in openscad. The problem I cannot
> solve is on lines 4 and 8- one of triple backslashes needed to escape the
> double quotes is showing in the text. If I remove one of the backslashes,
> the json longer works.
>
> I have attached the relevant json file- any suggestions to remove the
> extra slashes from the openscad display gratefully received.
>
> 1 include <BOSL2/std.scad>
> 2 include <BOSL2/threading.scad>
> 3 //Example of use of this module in a project
> 4 //Place \"use <C:/ownCloud/openscad files/text_module.scad>\"
> 5 //at the top of the project (without the quotes)
> 6 //Then in the appropriate place(s), place required height without
> quotes, then required text in quotes and the required font & style in
> quotes,
> 7 // then the size without quotes- eg.
> 8 //place_text(2,\"VK7KRJ\",\"Liberation Sans:style=Bold\",6);
> 9 use <C:/ownCloud/openscad files/0 examples/text_module.scad>
> 10 use <C:/ownCloud/openscad files/0 examples/heatset hole modules/3mm
> heatset insert hole module.scad>
> 11 $fn = 128;
>
>
> On 2025-05-25 10:10, Torsten Paul via Discuss wrote:
> > It's not fully automatic, but maybe a bit more flexible...
> >
> > Create a "templates" subfolder in the configuration directory,
> > e.g. on Linux: $HOME/.config/OpenSCAD/templates
> >
> > Into that folder, put a file, e.g. called header.json with the
> > following content (including the curly braces)
> >
> > {
> > "key" : "MyHeader",
> > "content" : "// Hi There!\n// This is my very special
> template\n\n^~^"
> > }
> >
> > Use ALT+Ins (no idea what that would be on macOS), or use
> > mouse right-click -> insert template. Select "MyHeader" in
> > the popup.
> >
> > The "^~^" is the marker where to place the cursor.
> >
> > ciao,
> > Torsten.
>
> --
> Cheers, Ken
> bats059@gmail.com
> https://vk7krj.com
> https://vk7krj.com/running.html
> ----------------------------------------
> A baby can be defined as an ego with a noise at one end and a smell at the
> other.
> Your job as parents is to teach them to control all three.
> My job as a grandad is to tell you how you are doing it all wrong!
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
L
larry
Mon, May 26, 2025 4:17 AM
On Sun, 2025-05-25 at 18:20 +0200, Torsten Paul via Discuss wrote:
On 25.05.25 18:06, larry via Discuss wrote:
When I use ALT+Ins, I get a list of (presumably) templates.
Where are they coming from?
Those are shipped with OpenSCAD. They are stored in a templates
folder inside the "Resource Path" (see Help->Library Info).
OK. So that brings up another question. Which directory should I store
them in?
The Resource Path directory files seems pretty funky. The files are
read-only, and I can't remove them, even with 'sudo rm -f'.
I would like to get rid of a few templates (at minimum, CC0.json). Any
idea how I can?
Some investigation tells me that the templates in my .config directory
override the ones in the Resource Path.
I haven't played with .json files at all. If I wanted to put another
template in the file, for example, 'module', how would I do that?
Just that simple. Thanks.
On Sun, 2025-05-25 at 18:20 +0200, Torsten Paul via Discuss wrote:
> On 25.05.25 18:06, larry via Discuss wrote:
> > When I use ALT+Ins, I get a list of (presumably) templates.
> > Where are they coming from?
>
> Those are shipped with OpenSCAD. They are stored in a templates
> folder inside the "Resource Path" (see Help->Library Info).
OK. So that brings up another question. Which directory should I store
them in?
The Resource Path directory files seems pretty funky. The files are
read-only, and I can't remove them, even with 'sudo rm -f'.
I would like to get rid of a few templates (at minimum, CC0.json). Any
idea how I can?
Some investigation tells me that the templates in my .config directory
override the ones in the Resource Path.
> > I haven't played with .json files at all. If I wanted to put another
> > template in the file, for example, 'module', how would I do that?
>
> One file = one template.
Just that simple. Thanks.
L
larry
Mon, May 26, 2025 4:23 PM
On Sun, 2025-05-25 at 22:17 -0600, larry via Discuss wrote:
On Sun, 2025-05-25 at 18:20 +0200, Torsten Paul via Discuss wrote:
On 25.05.25 18:06, larry via Discuss wrote:
When I use ALT+Ins, I get a list of (presumably) templates.
Where are they coming from?
Those are shipped with OpenSCAD. They are stored in a templates
folder inside the "Resource Path" (see Help->Library Info).
OK. So that brings up another question. Which directory should I store
them in?
The Resource Path directory files seems pretty funky. The files are
read-only, and I can't remove them, even with 'sudo rm -f'.
I would like to get rid of a few templates (at minimum, CC0.json). Any
idea how I can?
I asked a buddy about this, and he says it's because it's part of the
AppImage, so I'll just live with it.
Some investigation tells me that the templates in my .config directory
override the ones in the Resource Path.
This is good behaviour.
Thanks a bunch Torsten!
I haven't played with .json files at all. If I wanted to put another
template in the file, for example, 'module', how would I do that?
On Sun, 2025-05-25 at 22:17 -0600, larry via Discuss wrote:
> On Sun, 2025-05-25 at 18:20 +0200, Torsten Paul via Discuss wrote:
> > On 25.05.25 18:06, larry via Discuss wrote:
> > > When I use ALT+Ins, I get a list of (presumably) templates.
> > > Where are they coming from?
> >
> > Those are shipped with OpenSCAD. They are stored in a templates
> > folder inside the "Resource Path" (see Help->Library Info).
>
> OK. So that brings up another question. Which directory should I store
> them in?
>
> The Resource Path directory files seems pretty funky. The files are
> read-only, and I can't remove them, even with 'sudo rm -f'.
>
> I would like to get rid of a few templates (at minimum, CC0.json). Any
> idea how I can?
I asked a buddy about this, and he says it's because it's part of the
AppImage, so I'll just live with it.
> Some investigation tells me that the templates in my .config directory
> override the ones in the Resource Path.
This is good behaviour.
Thanks a bunch Torsten!
> > > I haven't played with .json files at all. If I wanted to put another
> > > template in the file, for example, 'module', how would I do that?
> >
> > One file = one template.
>
> Just that simple. Thanks.
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
JB
Jordan Brown
Tue, May 27, 2025 1:55 AM
On 5/25/2025 6:37 AM, Ken via Discuss wrote:
Thanks Torsten, excellent suggestion. After a bit of reading up on
json syntax, I have my header more or less working.
One small problem I have is with the escaping of double quotes.
Below is how my header file now looks in openscad. The problem I
cannot solve is on lines 4 and 8- one of triple backslashes needed to
escape the double quotes is showing in the text. If I remove one of
the backslashes, the json longer works.
This is the nightmare of multiple levels of encoding.
Say you want to put the two characters " (backslash and double quote)
into an OpenSCAD string.
Both of those characters are magic in OpenSCAD strings (as in any
C-derived language), so you need to put backslashes in front of them.
Thus your original two characters " become four: \". With the
quotes that surround the string you've got "\"".
Now you want to embed that OpenSCAD string in JSON in a template. JSON
is a C-derived language (by way of JavaScript and Java), so it needs
backslashes in front of magic characters. Thus that string becomes
"\\\"". And then you wrap that in the double quotes that JSON puts
around strings, and get ""\\\""".
Thus a template that echoes that string looks like so:
{
"key" : "MyEcho",
"content" : "echo(\"\\\\\\\"\");\n"
}
and inserts:
echo("\\\"");
and outputs (including the quotes that echo() adds:
ECHO: "\""
On 5/25/2025 6:37 AM, Ken via Discuss wrote:
> Thanks Torsten, excellent suggestion. After a bit of reading up on
> json syntax, I have my header more or less working.
> One small problem I have is with the escaping of double quotes.
>
> Below is how my header file now looks in openscad. The problem I
> cannot solve is on lines 4 and 8- one of triple backslashes needed to
> escape the double quotes is showing in the text. If I remove one of
> the backslashes, the json longer works.
This is the nightmare of multiple levels of encoding.
Say you want to put the two characters \" (backslash and double quote)
into an OpenSCAD string.
Both of those characters are magic in OpenSCAD strings (as in any
C-derived language), so you need to put backslashes in front of them.
Thus your original two characters \" become four: \\\". With the
quotes that surround the string you've got "\\\"".
Now you want to embed that OpenSCAD string in JSON in a template. JSON
is a C-derived language (by way of JavaScript and Java), so it needs
backslashes in front of magic characters. Thus that string becomes
\"\\\\\\\"\". And then you wrap that in the double quotes that JSON puts
around strings, and get "\"\\\\\\\"\"".
Thus a template that echoes that string looks like so:
{
"key" : "MyEcho",
"content" : "echo(\"\\\\\\\"\");\n"
}
and inserts:
echo("\\\"");
and outputs (including the quotes that echo() adds:
ECHO: "\""
K
Ken
Wed, May 28, 2025 1:28 AM
Thanks Jordan, with your help I finally have it sorted.
And being a lazy typist I can see me making great use of templates in the future!
On 2025-05-27 11:55, Jordan Brown wrote:
On 5/25/2025 6:37 AM, Ken via Discuss wrote:
Thanks Torsten, excellent suggestion. After a bit of reading up on json syntax, I have my header more or less working.
One small problem I have is with the escaping of double quotes.
Below is how my header file now looks in openscad. The problem I cannot solve is on lines 4 and 8- one of triple backslashes needed to escape the double quotes is showing in the text. If I remove one of the backslashes, the json longer works.
This is the nightmare of multiple levels of encoding.
Say you want to put the two characters " (backslash and double quote) into an OpenSCAD string.
Both of those characters are magic in OpenSCAD strings (as in any C-derived language), so you need to put backslashes in front of them. Thus your original two characters " become four: \". With the quotes that surround the string you've got "\"".
Now you want to embed that OpenSCAD string in JSON in a template. JSON is a C-derived language (by way of JavaScript and Java), so it needs backslashes in front of magic characters. Thus that string becomes "\\\"". And then you wrap that in the double quotes that JSON puts around strings, and get ""\\\""".
Thus a template that echoes that string looks like so:
{
"key" : "MyEcho",
"content" : "echo(\"\\\\\\\"\");\n"
}
and inserts:
echo("\\\"");
and outputs (including the quotes that echo() adds:
ECHO: "\""
A baby can be defined as an ego with a noise at one end and a smell at the other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!
Thanks Jordan, with your help I finally have it sorted.
And being a lazy typist I can see me making great use of templates in the future!
On 2025-05-27 11:55, Jordan Brown wrote:
> On 5/25/2025 6:37 AM, Ken via Discuss wrote:
>> Thanks Torsten, excellent suggestion. After a bit of reading up on json syntax, I have my header more or less working.
>> One small problem I have is with the escaping of double quotes.
>>
>> Below is how my header file now looks in openscad. The problem I cannot solve is on lines 4 and 8- one of triple backslashes needed to escape the double quotes is showing in the text. If I remove one of the backslashes, the json longer works.
>
> This is the nightmare of multiple levels of encoding.
>
> Say you want to put the two characters \" (backslash and double quote) into an OpenSCAD string.
>
> Both of those characters are magic in OpenSCAD strings (as in any C-derived language), so you need to put backslashes in front of them. Thus your original two characters \" become four: \\\". With the quotes that surround the string you've got "\\\"".
>
> Now you want to embed that OpenSCAD string in JSON in a template. JSON is a C-derived language (by way of JavaScript and Java), so it needs backslashes in front of magic characters. Thus that string becomes \"\\\\\\\"\". And then you wrap that in the double quotes that JSON puts around strings, and get "\"\\\\\\\"\"".
>
> Thus a template that echoes that string looks like so:
>
> {
> "key" : "MyEcho",
> "content" : "echo(\"\\\\\\\"\");\n"
> }
>
> and inserts:
>
> echo("\\\"");
>
> and outputs (including the quotes that echo() adds:
>
> ECHO: "\""
>
>
--
Cheers, Ken
bats059@gmail.com
https://vk7krj.com
https://vk7krj.com/running.html
----------------------------------------
A baby can be defined as an ego with a noise at one end and a smell at the other.
Your job as parents is to teach them to control all three.
My job as a grandad is to tell you how you are doing it all wrong!