discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

function-import

L
larry
Mon, Oct 6, 2025 6:01 AM

A fellow on the 'OpenSCAD Academy' group on Facebook has asked a
question about function-import. I have never used it, so I can't help
him.
I have suggested he join this list, but I don't know if he will.

He enabled function-import and tried this...

slice2=("file.svg");

He gets an 'unable to parse' error.

I tried a few variations, but only got errors.

Could someone either answer his question on Facebook or give me an
example I could pass on to him

L

A fellow on the 'OpenSCAD Academy' group on Facebook has asked a question about function-import. I have never used it, so I can't help him. I have suggested he join this list, but I don't know if he will. He enabled function-import and tried this... slice2=("file.svg"); He gets an 'unable to parse' error. I tried a few variations, but only got errors. Could someone either answer his question on Facebook or give me an example I could pass on to him L
TP
Torsten Paul
Mon, Oct 6, 2025 1:13 PM

On 06.10.25 08:01, larry via Discuss wrote:

Could someone either answer his question on Facebook

I don't use Facebook.

or give me an example I could pass on to him

The function style import can only import data and
not geometry.

At this point, only JSON files are supported, that
may be extended in the future.

ciao,
Torsten.

On 06.10.25 08:01, larry via Discuss wrote: > Could someone either answer his question on Facebook I don't use Facebook. > or give me an example I could pass on to him The function style import can *only* import data and not geometry. At this point, only JSON files are supported, that may be extended in the future. ciao, Torsten.
L
larry
Mon, Oct 6, 2025 1:17 PM

On Mon, 2025-10-06 at 15:13 +0200, Torsten Paul via Discuss wrote:

On 06.10.25 08:01, larry via Discuss wrote:

Could someone either answer his question on Facebook

I don't use Facebook.

I use it to help folks with 3D printing and such.

or give me an example I could pass on to him

The function style import can only import data and
not geometry.

At this point, only JSON files are supported, that
may be extended in the future.

Thanks. I'll pass that on to him.

L

On Mon, 2025-10-06 at 15:13 +0200, Torsten Paul via Discuss wrote: > On 06.10.25 08:01, larry via Discuss wrote: > > Could someone either answer his question on Facebook > > I don't use Facebook. I use it to help folks with 3D printing and such. > > or give me an example I could pass on to him > > The function style import can *only* import data and > not geometry. > > At this point, only JSON files are supported, that > may be extended in the future. Thanks. I'll pass that on to him. L
JB
Jordan Brown
Mon, Oct 6, 2025 4:40 PM

On 10/5/2025 11:01 PM, larry via Discuss wrote:

A fellow on the 'OpenSCAD Academy' group on Facebook has asked a
question about function-import. I have never used it, so I can't help
him.
I have suggested he join this list, but I don't know if he will.

He enabled function-import and tried this...

slice2=("file.svg");

He gets an 'unable to parse' error.

I tried a few variations, but only got errors.

Could someone either answer his question on Facebook or give me an
example I could pass on to him

The import function imports JSON data and returns it as OpenSCAD data.

It handles most or maybe all JSON files.

It handles only JSON files; it does not (yet?) handle any other file type.

On 10/5/2025 11:01 PM, larry via Discuss wrote: > A fellow on the 'OpenSCAD Academy' group on Facebook has asked a > question about function-import. I have never used it, so I can't help > him. > I have suggested he join this list, but I don't know if he will. > > He enabled function-import and tried this... > > slice2=("file.svg"); > > He gets an 'unable to parse' error. > > I tried a few variations, but only got errors. > > Could someone either answer his question on Facebook or give me an > example I could pass on to him The import function imports JSON data and returns it as OpenSCAD data. It handles most or maybe all JSON files. It handles only JSON files; it does not (yet?) handle any other file type.
WF
William F. Adams
Mon, Oct 6, 2025 5:12 PM

Is the basic importing of an SVG outline not what is wanted?

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry/SVG_Import

William

Is the basic importing of an SVG outline not what is wanted? https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry/SVG_Import William
L
larry
Mon, Oct 6, 2025 5:13 PM

On Mon, 2025-10-06 at 09:40 -0700, Jordan Brown wrote:

On 10/5/2025 11:01 PM, larry via Discuss wrote:
 

A fellow on the 'OpenSCAD Academy' group on Facebook has asked a
question about function-import. I have never used it, so I can't
help
him.
I have suggested he join this list, but I don't know if he will.

He enabled function-import and tried this...

slice2=("file.svg");

He gets an 'unable to parse' error.

I tried a few variations, but only got errors.

Could someone either answer his question on Facebook or give me an
example I could pass on to him

 
 The import function imports JSON data and returns it as OpenSCAD
data.
It handles most or maybe all JSON files.
 It handles only JSON files; it does not (yet?) handle any other file
type.

That brings up another question (mine, this time).
Is there a way to get a json representation of an svg file?

L

On Mon, 2025-10-06 at 09:40 -0700, Jordan Brown wrote: > On 10/5/2025 11:01 PM, larry via Discuss wrote: >   > > A fellow on the 'OpenSCAD Academy' group on Facebook has asked a > > question about function-import. I have never used it, so I can't > > help > > him. > > I have suggested he join this list, but I don't know if he will. > > > > He enabled function-import and tried this... > > > > slice2=("file.svg"); > > > > He gets an 'unable to parse' error. > > > > I tried a few variations, but only got errors. > > > > Could someone either answer his question on Facebook or give me an > > example I could pass on to him >   >  The import function imports JSON data and returns it as OpenSCAD > data. > It handles most or maybe all JSON files. >  It handles only JSON files; it does not (yet?) handle any other file > type. That brings up another question (mine, this time). Is there a way to get a json representation of an svg file? L
JB
Jordan Brown
Mon, Oct 6, 2025 5:20 PM

On 10/6/2025 10:12 AM, William F. Adams via Discuss wrote:

Is the basic importing of an SVG outline not what is wanted?

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry/SVG_Import

Repeat after me:  functions are not modules, and modules are not functions.

If it's in an expression, it's a function.  If it's not, if it's at the
top level (or is the child of another module), it's a module.

The import module imports a variety of geometry-defining file types: 
STL, 3MF, SVG, DXF, et cetera, and adds them to the model.

The import function imports JSON and returns it as data.

One might want a function that imports a geometry-defining file type and
returns it as data, but we do not (yet?) have such a function.

If you are still uncertain about functions and modules, play with this:

function foo() = "I am a function";
module foo() { echo("I am a module"); }

echo(foo());
foo();
On 10/6/2025 10:12 AM, William F. Adams via Discuss wrote: > Is the basic importing of an SVG outline not what is wanted? > > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry/SVG_Import Repeat after me:  functions are not modules, and modules are not functions. If it's in an expression, it's a function.  If it's not, if it's at the top level (or is the child of another module), it's a module. The import *module* imports a variety of geometry-defining file types:  STL, 3MF, SVG, DXF, et cetera, and adds them to the model. The import *function* imports JSON and returns it as data. One might want a function that imports a geometry-defining file type and returns it as data, but we do not (yet?) have such a function. If you are still uncertain about functions and modules, play with this: function foo() = "I am a function"; module foo() { echo("I am a module"); } echo(foo()); foo();
JB
Jordan Brown
Mon, Oct 6, 2025 5:25 PM

On 10/6/2025 10:13 AM, larry wrote:

Is there a way to get a json representation of an svg file?

It looks like there are several tools to do that:
https://www.google.com/search?q=translate+svg+to+json

I know nothing about them.

On 10/6/2025 10:13 AM, larry wrote: > Is there a way to get a json representation of an svg file? It looks like there are several tools to do that: https://www.google.com/search?q=translate+svg+to+json I know nothing about them.
L
larry
Mon, Oct 6, 2025 5:40 PM

On Mon, 2025-10-06 at 10:25 -0700, Jordan Brown wrote:

On 10/6/2025 10:13 AM, larry wrote:

Is there a way to get a json representation of an svg file?

 It looks like there are several tools to do that:
 https://www.google.com/search?q=translate+svg+to+json
 I know nothing about them.

Thanks. I have only tried one so far. It gave me something that is
unrecognizable by me or OpenSCAD.

On Mon, 2025-10-06 at 10:25 -0700, Jordan Brown wrote: > On 10/6/2025 10:13 AM, larry wrote: > > Is there a way to get a json representation of an svg file? > >  It looks like there are several tools to do that: >  https://www.google.com/search?q=translate+svg+to+json >  I know nothing about them. Thanks. I have only tried one so far. It gave me something that is unrecognizable by me or OpenSCAD.
JB
Jordan Brown
Mon, Oct 6, 2025 6:04 PM

On 10/6/2025 10:40 AM, larry wrote:

On Mon, 2025-10-06 at 10:25 -0700, Jordan Brown wrote:

On 10/6/2025 10:13 AM, larry wrote:

Is there a way to get a json representation of an svg file?

 It looks like there are several tools to do that:
 https://www.google.com/search?q=translate+svg+to+json
 I know nothing about them.

Thanks. I have only tried one so far. It gave me something that is
unrecognizable by me or OpenSCAD.

If you don't mind, please privately e-mail me the files and a pointer to
the tool.  If it's valid JSON and OpenSCAD doesn't import it, I'd like
to know why.

On 10/6/2025 10:40 AM, larry wrote: > On Mon, 2025-10-06 at 10:25 -0700, Jordan Brown wrote: >> On 10/6/2025 10:13 AM, larry wrote: >>> Is there a way to get a json representation of an svg file? >>  It looks like there are several tools to do that: >>  https://www.google.com/search?q=translate+svg+to+json >>  I know nothing about them. > Thanks. I have only tried one so far. It gave me something that is > unrecognizable by me or OpenSCAD. If you don't mind, please privately e-mail me the files and a pointer to the tool.  If it's valid JSON and OpenSCAD doesn't import it, I'd like to know why.