discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

strange error trying to import svg

BR
Bob Roos
Thu, Mar 28, 2024 8:42 PM

Hello OpenSCAD,

I tried this both with a relative path and a fully specified path.  It mixes up the slash and back slash on both and on the full path puts it after the current folder name where the .scad file is saved

I have 2021.01 installed

Bob Roos

// usps logo for sonny
// bob roos
// march 28, 2024

import(file = "2 color usps for sunny.svg", center = false, dpi = 96);

//ERROR: Can't open file 'C:/Users/wybat/Projects/3D Projects/For others\2 color usps for sunny.svg', import() at line 6

--
Best regards,
Bob                          mailto:roosbob@wybatap.com

Hello OpenSCAD, I tried this both with a relative path and a fully specified path. It mixes up the slash and back slash on both and on the full path puts it after the current folder name where the .scad file is saved I have 2021.01 installed Bob Roos // usps logo for sonny // bob roos // march 28, 2024 import(file = "2 color usps for sunny.svg", center = false, dpi = 96); //ERROR: Can't open file 'C:/Users/wybat/Projects/3D Projects/For others\2 color usps for sunny.svg', import() at line 6 -- Best regards, Bob mailto:roosbob@wybatap.com
JB
Jordan Brown
Thu, Mar 28, 2024 8:56 PM

On 3/28/2024 1:42 PM, Bob Roos via Discuss wrote:

I tried this both with a relative path and a fully specified path.  It mixes up the slash and back slash on both and on the full path puts it after the current folder name where the .scad file is saved

I have 2021.01 installed

Bob Roos

// usps logo for sonny
// bob roos
// march 28, 2024

import(file = "2 color usps for sunny.svg", center = false, dpi = 96);

//ERROR: Can't open file 'C:/Users/wybat/Projects/3D Projects/For others\2 color usps for sunny.svg', import() at line 6

Generally speaking, under Windows you can use forward or backslashes, or
a mixture.  Do remember that if you use backslashes, you need to double
them so they survive string processing.  The pattern that you see here
is arguably stupid, but is the same as the pattern that I see in 2021.01
and in 2024.03.05.

So the big question is:  does that file exist at that path?  Check both
the file and the path carefully.  "Projects" is unusual as a
subdirectory under \users\somebody, which doesn't make it wrong but
makes it suspicious.

On 3/28/2024 1:42 PM, Bob Roos via Discuss wrote: > I tried this both with a relative path and a fully specified path. It mixes up the slash and back slash on both and on the full path puts it after the current folder name where the .scad file is saved > > I have 2021.01 installed > > Bob Roos > > > // usps logo for sonny > // bob roos > // march 28, 2024 > > > import(file = "2 color usps for sunny.svg", center = false, dpi = 96); > > //ERROR: Can't open file 'C:/Users/wybat/Projects/3D Projects/For others\2 color usps for sunny.svg', import() at line 6 Generally speaking, under Windows you can use forward or backslashes, or a mixture.  Do remember that if you use backslashes, you need to double them so they survive string processing.  The pattern that you see here is arguably stupid, but is the same as the pattern that I see in 2021.01 and in 2024.03.05. So the big question is:  does that file exist at that path?  Check both the file and the path carefully.  "Projects" is unusual as a subdirectory under \users\somebody, which doesn't make it wrong but makes it suspicious.
JB
Jordan Brown
Thu, Mar 28, 2024 10:04 PM

Also try finding the file in Windows Explorer, then dragging the SVG
file to your OpenSCAD editor pane.  It should insert an import() call;
you could check to see if that works and compare it against your
previous attempts.

Also try finding the file in Windows Explorer, then dragging the SVG file to your OpenSCAD editor pane.  It should insert an import() call; you could check to see if that works and compare it against your previous attempts.
FH
Father Horton
Thu, Mar 28, 2024 10:19 PM

You might also try specifying the full path.

On Thu, Mar 28, 2024 at 5:04 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

Also try finding the file in Windows Explorer, then dragging the SVG file
to your OpenSCAD editor pane.  It should insert an import() call; you could
check to see if that works and compare it against your previous attempts.


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

You might also try specifying the full path. On Thu, Mar 28, 2024 at 5:04 PM Jordan Brown via Discuss < discuss@lists.openscad.org> wrote: > Also try finding the file in Windows Explorer, then dragging the SVG file > to your OpenSCAD editor pane. It should insert an import() call; you could > check to see if that works and compare it against your previous attempts. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JB
Jon Bondy
Fri, Mar 29, 2024 1:00 AM

Jordan:

Does this trick work for any files other than SVG?

Jon

On 3/28/2024 6:04 PM, Jordan Brown via Discuss wrote:

Also try finding the file in Windows Explorer, then dragging the SVG
file to your OpenSCAD editor pane.  It should insert an import() call;
you could check to see if that works and compare it against your
previous attempts.


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

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

Jordan: Does this trick work for any files other than SVG? Jon On 3/28/2024 6:04 PM, Jordan Brown via Discuss wrote: > Also try finding the file in Windows Explorer, then dragging the SVG > file to your OpenSCAD editor pane.  It should insert an import() call; > you could check to see if that works and compare it against your > previous attempts. > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG antivirus software. www.avg.com
RW
Rogier Wolff
Fri, Mar 29, 2024 12:07 PM

On Thu, Mar 28, 2024 at 04:42:09PM -0400, Bob Roos via Discuss wrote:

Hello OpenSCAD,

I tried this both with a relative path and a fully specified path.
It mixes up the slash and back slash on both and on the full path
puts it after the current folder name where the .scad file is saved

Workaround: Get rid of the spaces in the path names and filenames.
(But I agree: this should be fixed).

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Thu, Mar 28, 2024 at 04:42:09PM -0400, Bob Roos via Discuss wrote: > Hello OpenSCAD, > I tried this both with a relative path and a fully specified path. > It mixes up the slash and back slash on both and on the full path > puts it after the current folder name where the .scad file is saved Workaround: Get rid of the spaces in the path names and filenames. (But I agree: this should be fixed). Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
TP
Torsten Paul
Fri, Mar 29, 2024 5:12 PM

On 29.03.24 13:07, Rogier Wolff via Discuss wrote:

Workaround: Get rid of the spaces in the path names and filenames.
(But I agree: this should be fixed).

I don't see any conclusion this is the problem. So maybe we don't
toss around advice until it's clear what the issue actually is?

Spaces are not a problem with import generally, I've used files with
spaces in path a number of times without issue (although not on
Windows, so we have to see if it might be a platform specific issue).

Same goes for the slash vs. backslash, at this point it may look
a bit annoying, but if that would be a general issue it would have
come up before much more often.
As far as I know, people are free to use both in the path specified
in the script, and OpenSCAD internally will use the platform default.
So there is no simple or correct way of "fixing" it as it should
even work when mixing both in the script itself.
For nicer looking output it could be normalized to always use
the same separator, but I'm sure some people will complain if that
does then not match what's typed in the script.

The drag&drop works for (hopefully?) all importable files:
stl, obj, 3mf, off, dxf, svg, amf
and will generate a surface statement for
dat, png
the snapshot version should also create an import function
call for json files.

ciao,
Torsten.

On 29.03.24 13:07, Rogier Wolff via Discuss wrote: > Workaround: Get rid of the spaces in the path names and filenames. > (But I agree: this should be fixed). I don't see *any* conclusion this is the problem. So maybe we don't toss around advice until it's clear what the issue actually is? Spaces are not a problem with import generally, I've used files with spaces in path a number of times without issue (although not on Windows, so we have to see if it might be a platform specific issue). Same goes for the slash vs. backslash, at this point it may look a bit annoying, but if that would be a general issue it would have come up before much more often. As far as I know, people are free to use both in the path specified in the script, and OpenSCAD internally will use the platform default. So there is no simple or correct way of "fixing" it as it should even work when mixing both in the script itself. For nicer looking output it could be normalized to always use the same separator, but I'm sure some people will complain if that does then not match what's typed in the script. The drag&drop works for (hopefully?) all importable files: stl, obj, 3mf, off, dxf, svg, amf and will generate a surface statement for dat, png the snapshot version should also create an import function call for json files. ciao, Torsten.
RW
Rogier Wolff
Sat, Mar 30, 2024 8:48 AM

On Fri, Mar 29, 2024 at 06:12:42PM +0100, Torsten Paul via Discuss wrote:

On 29.03.24 13:07, Rogier Wolff via Discuss wrote:

Workaround: Get rid of the spaces in the path names and filenames.
(But I agree: this should be fixed).

I don't see any conclusion this is the problem. So maybe we don't
toss around advice until it's clear what the issue actually is?

Yeah. I might've been a bit too much "jumping to conclusions".

But it is easy for the poster to try and if he reports back
"works" or "doesn't help", that's a useful datapoint to debug
the problem. So I'm still hoping he tries my suggestion and
reports what happens.

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

On Fri, Mar 29, 2024 at 06:12:42PM +0100, Torsten Paul via Discuss wrote: > On 29.03.24 13:07, Rogier Wolff via Discuss wrote: > > Workaround: Get rid of the spaces in the path names and filenames. > > (But I agree: this should be fixed). > > I don't see *any* conclusion this is the problem. So maybe we don't > toss around advice until it's clear what the issue actually is? Yeah. I might've been a bit too much "jumping to conclusions". But it is easy for the poster to try and if he reports back "works" or "doesn't help", that's a useful datapoint to debug the problem. So I'm still hoping he tries my suggestion and reports what happens. Roger. -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
BR
Bob Roos
Sat, Mar 30, 2024 11:51 AM

Hi Bob,

// original line copied from import discussion from lcheat sheet: import("example012.stl", convexity=3);

import("C:\Users\wybat\Dropbox\Apps\line logo red small.svg", convexity=3);
/*

Parsing design (AST generation)...
Saved backup file: C:/Users/wybat/OneDrive/Documents/OpenSCAD/backups/usps logo for sonny-backup-qYNrXOqd.scad
Compiling design (CSG Tree generation)...
Compiling design (CSG Products generation)...
ERROR: Can't open file 'C:/Users/wybat/AppData/Roaming/Microsoft/Windows\C:UserswybatDropboxAppsline logo red small.svg', import() at line 4
Geometries in cache: 4326
Geometry cache size in bytes: 49535680
CGAL Polyhedrons in cache: 1
CGAL cache size in bytes: 83654352
Compiling design (CSG Products normalization)...
Normalized tree has 1 elements!
Compile and preview finished.

*/

/*
pressed F5 again without changing anything and it ran OK

The file and path were put on the clipboard by the program Search Everything (voidtools.com) I use it all the time to get fle paths with no problems)

You can see that OpenSCAD completely mangled the path to the file by adding in its working folder path in front of the path that I specified.

I tried to reproduce and sometimes it would work without an error.
*/

Thursday, March 28, 2024, 4:42:09 PM, you wrote:

Hello OpenSCAD,

I tried this both with a relative path and a fully specified path.  It mixes up the slash and back slash on both and on the full path puts it after the current folder name where the .scad file is saved

I have 2021.01 installed

Bob Roos

// usps logo for sonny
// bob roos
// march 28, 2024

import(file = "2 color usps for sunny.svg", center = false, dpi = 96);

//ERROR: Can't open file 'C:/Users/wybat/Projects/3D Projects/For others\2 color usps for sunny.svg', import() at line 6

--
have Fun,
Bob                          mailto:roosbob@wybatap.com

Hi Bob, // original line copied from import discussion from lcheat sheet: import("example012.stl", convexity=3); import("C:\Users\wybat\Dropbox\Apps\line logo red small.svg", convexity=3); /* Parsing design (AST generation)... Saved backup file: C:/Users/wybat/OneDrive/Documents/OpenSCAD/backups/usps logo for sonny-backup-qYNrXOqd.scad Compiling design (CSG Tree generation)... Compiling design (CSG Products generation)... ERROR: Can't open file 'C:/Users/wybat/AppData/Roaming/Microsoft/Windows\C:UserswybatDropboxAppsline logo red small.svg', import() at line 4 Geometries in cache: 4326 Geometry cache size in bytes: 49535680 CGAL Polyhedrons in cache: 1 CGAL cache size in bytes: 83654352 Compiling design (CSG Products normalization)... Normalized tree has 1 elements! Compile and preview finished. */ /* pressed F5 again without changing anything and it ran OK The file and path were put on the clipboard by the program Search Everything (voidtools.com) I use it all the time to get fle paths with no problems) You can see that OpenSCAD completely mangled the path to the file by adding in its working folder path in front of the path that I specified. I tried to reproduce and sometimes it would work without an error. */ Thursday, March 28, 2024, 4:42:09 PM, you wrote: > Hello OpenSCAD, > I tried this both with a relative path and a fully specified path. It mixes up the slash and back slash on both and on the full path puts it after the current folder name where the .scad file is saved > I have 2021.01 installed > Bob Roos > // usps logo for sonny > // bob roos > // march 28, 2024 > import(file = "2 color usps for sunny.svg", center = false, dpi = 96); > > //ERROR: Can't open file 'C:/Users/wybat/Projects/3D Projects/For others\2 color usps for sunny.svg', import() at line 6 -- have Fun, Bob mailto:roosbob@wybatap.com
JB
Jordan Brown
Sat, Mar 30, 2024 11:19 PM

[ rearranged a little to get related comments together ]

On 3/30/2024 4:51 AM, Bob Roos via Discuss wrote:

import("C:\Users\wybat\Dropbox\Apps\line logo red small.svg", convexity=3);
[...]
ERROR: Can't open file 'C:/Users/wybat/AppData/Roaming/Microsoft/Windows\C:UserswybatDropboxAppsline logo red small.svg', import() at line 4

The file and path were put on the clipboard by the program Search Everything (voidtools.com) I use it all the time to get fle paths with no problems)

You can see that OpenSCAD completely mangled the path to the file by adding in its working folder path in front of the path that I specified.

More importantly, it mangled the path by stripping out backslashes,
which is standard string processing.

No matter whether you type or copy-paste the string, backslashes are
magic.  If you want a real backslash in the string, as you do here, you
must double it.
Or you can use forward slashes.

You want one of :

import("C:\\Users\\wybat\\Dropbox\\Apps\\line logo red small.svg", convexity=3);

import("C:/Users/wybat/Dropbox/Apps/line logo red small.svg",
convexity=3);

This part is totally understood.

Try a simple test:

echo("C:\Users\wybat\Dropbox\Apps\line logo red small.svg");

which will yield

ECHO: "C:UserswybatDropboxAppsline logo red small.svg"

pressed F5 again without changing anything and it ran OK

I tried to reproduce and sometimes it would work without an error.

I think that what is going on there is that in some cases OpenSCAD
helpfully suppresses duplicate error messages.  It probably shouldn't do
that, or at least it should reset the duplicate suppression when you run
the program again.  Design/Flush Caches seems to reset that
duplicate-suppression mechanism.

[ rearranged a little to get related comments together ] On 3/30/2024 4:51 AM, Bob Roos via Discuss wrote: > import("C:\Users\wybat\Dropbox\Apps\line logo red small.svg", convexity=3); > [...] > ERROR: Can't open file 'C:/Users/wybat/AppData/Roaming/Microsoft/Windows\C:UserswybatDropboxAppsline logo red small.svg', import() at line 4 > > The file and path were put on the clipboard by the program Search Everything (voidtools.com) I use it all the time to get fle paths with no problems) > > You can see that OpenSCAD completely mangled the path to the file by adding in its working folder path in front of the path that I specified. More importantly, it mangled the path by stripping out backslashes, which is standard string processing. No matter whether you type or copy-paste the string, backslashes are magic.  If you want a real backslash in the string, as you do here, you must double it. Or you can use forward slashes. You want one of : import("C:\\Users\\wybat\\Dropbox\\Apps\\line logo red small.svg", convexity=3); import("C:/Users/wybat/Dropbox/Apps/line logo red small.svg", convexity=3); This part is totally understood. Try a simple test: echo("C:\Users\wybat\Dropbox\Apps\line logo red small.svg"); which will yield ECHO: "C:UserswybatDropboxAppsline logo red small.svg" > pressed F5 again without changing anything and it ran OK > > I tried to reproduce and sometimes it would work without an error. I think that what is going on there is that in some cases OpenSCAD helpfully suppresses duplicate error messages.  It probably shouldn't do that, or at least it should reset the duplicate suppression when you run the program again.  Design/Flush Caches seems to reset that duplicate-suppression mechanism.