Wings 3D Development Forum
SVG import more broken than before? - Printable Version

+- Wings 3D Development Forum (https://www.wings3d.com/forum)
+-- Forum: Wings 3D (https://www.wings3d.com/forum/forumdisplay.php?fid=1)
+--- Forum: Bug Reports (https://www.wings3d.com/forum/forumdisplay.php?fid=12)
+--- Thread: SVG import more broken than before? (/showthread.php?tid=2242)

Pages: 1 2


SVG import more broken than before? - jcoppens - 11-18-2016

Hi guys.

Maybe the title is a little too violent Smile I meant that the solutions presented in http://www.wings3d.com/forum/showthread.php?tid=108&highlight=svg didn't work at all in version 2.1.2.

I tried an SVG with just one (curved) line and many combinations of the options:

- From Inkscape, saved as normal SVG and as 'Plain SVG'
- Tried as Open curve ('internal error') and Closed curve. Imports nodes but no curve info (i.e. shows just a straight line).
- Tried to export from Inkscape as PS and EPS, import into Wings3d, with basically the same results (found a reference that PS/EPS import is broken?)
- Same curve seems to import correctly in blender.
- Strangely, a more complex SVG from Inkscape, with many open curves does _not_
create 'Internal errors', but doesn't import the curves either (again, nodes are imported but no curve info).

A separate question is why only closed curves/lines can be read?

I'd like to help debugging this but there's a language barrier (erlang) and absolute ignorance of debugging tools for same. I've installed erlang, and am starting a tutorial but I'd appreciate any useful pointers and suggestions!

EDIT:

Since writing this I did more tests, and until now, haven't been able to find any SVG which imports correctly:

- I created (manually) some very minimalistic, single object SVGs
- I used a pile of converters and graphics programs to import/convert/export SVGs
(BTW, Libreoffice/Openoffice Draw seems a nice vector graphics program)
- I used a similar quantity to check all I the SVGs for validity (see below)

Basically, I could not create a single SVG image which correctly imported in W3D.

A note on W3C SVG validator; I do get a lot of errors there, but most, if not all of them are not graphics related. As far as I can see, the importer doesn't do any checking.


RE: SVG import more broken than before? - tkbd - 11-19-2016

Hi!, jcoppens
I write only the questions that I can answer. Smile

Quote:- From Inkscape, saved as normal SVG and as 'Plain SVG'
- Tried as Open curve ('internal error') and Closed curve. Imports nodes but no curve info (i.e. shows just a straight line).

It probably will contains Bezier curve
When SVG file import dialog appeared ,did you try "Number of edge bisections" parameter to more than 2 ?
That time the curve is divided to multiple lines.
(I also use this tips to avoid error when make 3D Text primitive.)

Quote:- Tried to export from Inkscape as PS and EPS, import into Wings3d, with basically the same results (found a reference that PS/EPS import is broken?)

I also tried a PS / EPS file saved in Illustrator, but failded.

About these format:
  • EPS format is a program-able format. (Like program code,it takes variouse forms, For example it might be contains while loop,function macro. )
  • SVG format is a data set one kind of like XML(The structure of the data is determined from the beginning.).
So,about EPS,PS file, It seems to recognize only data that was made in a specific draw command.
(I have not read much code in detail of the svg importer...)
I expect it is the reason Wings 3D fails to load EPS/PS files.

Quote:- Same curve seems to import correctly in blender.
Blender can handle NURBS/Bezier curve and Path from imported data like Inkscape and Illustrator.

Quote:A separate question is why only closed curves/lines can be read?
Unfortunately,Wings can only handle polygons surface.
So these polygons must be surrounded by edgs( = this means closed line/curve).

Quote:I'd like to help debugging this but there's a language barrier (erlang) and absolute ignorance of debugging tools for same. I've installed erlang, and am starting a tutorial but I'd appreciate any useful pointers and suggestions!

I'm not programming specialist.
but I introduce the following pages used as studybooks. but The original page was lost already ;_; This info is useful for plugin module compile by alone

Cheers!


RE: SVG import more broken than before? - dgud - 11-19-2016

>I'd like to help debugging this but there's a language barrier (erlang) and absolute ignorance of debugging tools
>for same. I've installed erlang, and am starting a tutorial but I'd appreciate any useful pointers and suggestions!

Erlang is a functional language as: Lisp, Haskell, Closure so it's a bit different than the traditional programming languages, if you have programmed a functional language it will be easy to learn since it is very small, if not it will be different :-)

The best part of Erlang is it's concurrent features, which we don't use much in wings right now, Erlang behaves more like an OS with a lot of processes talking to each other.

The best written docs are here:
http://learnyousomeerlang.com/content

We have a debugger, started with debuggerConfusedtart() from the erlang shell, which don't work with installed wings code since it's stripped of debug info, so you need to compile wings yourself.
Though the debugger is not used as much there are often simpler alternatives to use.

I have written another tool, observer that gives an overview of the running system
> observerConfusedtart().


First print debugging is the one I/we use the most, it's simple because in erlang you can reload code without
re-starting your program.

The basic debug loop is:
start wings
load model
do your command and see what going wrong.

Add io:format("DEBUG ~p", [Info]), in your code
re-compile file/module
load module to running wings: in shell: l(wings_object).
redo command

add io:format() ... repeat

There are scripts that load new compile code automatically when code is changed, which I use: Google says: https://github.com/oinksoft/reloader

There are other ways, we have really good tracing facilities in erlang where you can trace everything, function calls or process created or message sent/received.

You can do tracing from the gui (the observer application) or from the shell see dbg module.
But that is more complex so you have to google those instructions.


RE: SVG import more broken than before? - dgud - 11-19-2016

Also svg importer code is not where I would start learning erlang :-)
It is not the most beautiful erlang code ever written, but on the other hand there is much room for improvement.

There is also that most of wings code in src dir was/is written by Björn G who also writes the runtime system and compiler for erlang so every trick in the book is used :-)
See answer 4 (rate 7) in: http://stackoverflow.com/questions/1017017/what-is-the-best-way-to-learn-erlang


RE: SVG import more broken than before? - jcoppens - 11-19-2016

Quote:Erlang is a functional language as: Lisp, Haskell, Closure so it's a bit different than the traditional programming languages, if you have programmed a functional language it will be easy to learn since it is very small, if not it will be different :-)

Thanks for the reply and apologies for the delay. I'd hoped for (but didn't get) e-mail notifications of any postings here. I now seem to remember that I had to opt-in for those notifications...

I'm not un-familiar with functional languages (did a course in edx.org using the Mozart language). A long time ago I dabbled a little in Lisp. I hope I can manage Erlang enough to understand the issues. I'd be happy for any help though.

Also, thanks for the indications about the debugger.

Quote:It probably will contains Bezier curve
When SVG file import dialog appeared ,did you try "Number of edge bisections" parameter to more than 2 ?
That time the curve is divided to multiple lines.
(I also use this tips to avoid error when make 3D Text primitive.)

Yes. I tried up to 6 or 7. Of course, that way the figure starts looking better, as the number of segments approximate the original curve, but all line segments are still straight lines

Quote:I also tried a PS / EPS file saved in Illustrator, but failded.

Since the original post, I tried:

- manually a minimal SVG - just a (closed) curve segment
- tried minimal PS, EPS, AI, and other formats.
- also tried by generating SVGs with other programs
- created SVGs in several other programs
- imported all the test SVGs in other programs to check validity

I can't find any SVG importable in Wings3D. If anyone has an SVG importable
in Wings3d, I'd appreciate a copy!


Quote:Unfortunately,Wings can only handle polygons surface.
So these polygons must be surrounded by edgs( = this means closed line/curve).

Do these edges have to be straight edges (i.e. line segments)? The source code seems to indicate curve segments (%pmoveto, plineto, or pcurveto), And if curves are allowed, can't these be Bézier curves?


RE: SVG import more broken than before? - dgud - 11-19-2016

Quote:Also svg importer code is not where I would start learning erlang :-)
It is not the most beautiful erlang code ever written, but on the other hand there is much room for improvement.

I'll take that back, I have not looked at that code at all, I thought about something else.

Quote:Thanks for the reply and apologies for the delay. I'd hoped for (but didn't get) e-mail notifications of any postings here. I now seem to remember that I had to opt-in for those notifications...

It's a forum we read when we have time.

Quote:I'm not un-familiar with functional languages (did a course in edx.org using the Mozart language). A long time ago I dabbled a little in Lisp. I hope I can manage Erlang enough to understand the issues. I'd be happy for any help though.

A walk in the park then, once you got the hang of the syntax :-)


RE: SVG import more broken than before? - tkbd - 11-20-2016

jcoppens Wrote:I can't find any SVG importable in Wings3D. If anyone has an SVG importable
in Wings3d, I'd appreciate a copy!

I tested svg files made by some Draw applications ,and these files uploaded.(Inkscape,AffinityDesigner and AdobeIllustrator)
You can downlod them a following URL Wink
Wings3D SVG Importer test


Only file that exported by InkScape 0.91 succeeded in that.
(Note: the file applied "Object -> Path" convesion by InkScape)
I compared their svg sources.
In failed case , it using path, polygon and path tag.

Perhaps Wings will not correctly interpret lect tags and Polygon tags.
And if save a svg file created with InkScape with another draw software, it would be mixed various tags.

So,if it corresponds to any SVG file imort, it must also correspond to drawing tags other than the Path tag.
SVG path tag (w3school.com)


RE: SVG import more broken than before? - jcoppens - 11-20-2016

Quote:You can downlod them a following URL Wink
Wings3D SVG Importer test

Thank you for the examples! They are very helpful.


RE: SVG import more broken than before? - oort - 12-06-2016

Here is some background history on the svg import plugin. This is from the old forum...svg import plugin

P.S. The script for exporting .svg files that I had used in an older version of The Gimp no longer works in the newer version I have. Here is a link with information on how to export an svg path from The Gimp... Export SVG Path from The Gimp

Here is more information about Paths in The Gimp.... Gimp Paths Dialog

SVG import is working for me in Wings3D 2.1.4.1

oort


RE: SVG import more broken than before? - tkbd - 12-07-2016

Quote:Here is some background history on the svg import plugin. This is from the old forum...svg import plugin
Thank you helpful information.
The background history of svg import plugin, this is interesting.
Also,I tested saved SVG file by GIMPv2.9.5's path export(using Export path)
I could read it without any problems so far.

----------------------------------------------------------------------

By the way,I investigated how to convert to SVG<Path> element for shapes in Inkscape, AffinityDesigner and Illustrator.
Then,I could make the SVG file that contains <Path> element only, on each software.
However, an error still occurred when importing to Wings.

Illustrator and AffinityDesigner didn't separated by a space with SVG draw command and parameter figures .
For example Affinity Designer is export a following data.
Code:
<path d="M613.728,505.061L402.215,505.061L234.494,505.061L234.494,745.222L613.728,745.222L613.728,505.061Z" style="fill:rgb(235,235,235);"/>

So fix add space after Import OK (Incidentally,Inkscape use spacing)
<path d="M 613.728,505.061 L 402.215,505.061 L 234.494,505.061 L 234.494,745.222 L 613.728,745.222 L 613.728,505.061 Z" style="fill:rgb(235,235,235);"/>


For example Illustrator SVG faild, I saw H/h and V/v command (Vertical and Horizontal lineto) in Illustrator SVG data.
Code:
<path style="fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;" d="M438,331l-6-40h-61v29l-36,4l-9,27c0,0-25-5-25-5
    c-0.975,23.391-0.942,49.771,30.546,48.16c9.048-0.463,16.905-7.56,25.447-7.358c11.493,0.271,10.497,11.405,17.669,15.825
    c5.188,3.198,13.446,5.61,13.236-4.566c12.177-1.655,24.871,10.787,37.933,10.905c1.367-12.196-5.331-11.096-8.678-19.224
    c-5.319-12.921,16.718-19.29,19.932-29.46C439.703,351.995,437.726,339.775,438,331z"/>

For example Inkscape SVG failed ,Because Wings3D SVG importer not support "A" and "a" (Elliptical Arc) commands in <Path> Element.
It appears when convert an ellipse to Path.
Code:
d="m 428.57143,340.93362 a 65.714287,82.85714 0 0 1 -65.71428,82.85714 65.714287,82.85714 0 0 1 -65.71429,-82.85714 65.714287,82.85714 0 0 1 65.71429,-82.85714 65.714287,82.85714 0 0 1 65.71428,82.85714 z"

We can see this in Wings3D log window
Quote:File Import Error Report:
{'EXIT',{badarg,[{erlang,list_to_float,["a.0"],[]},
{wpc_svg_path,string_to_float,1,
[{file,"wpc_svg_path.erl"},{line,214}]},.

See the information about all command for <Path> elements
https://developer.mozilla.org/en/docs/Web/SVG/Tutorial/Paths

The current SVG Import plugin does not enough support variations of command and parameter description even if it is limited to Path element.
I hope these information will be useful for debugging someone. Smile