marvingreenberg / FaceSVG

SVG Export from Sketchup 3D modeling tool
MIT License
49 stars 3 forks source link

SVG file not working in Illustrator #31

Closed coogle closed 4 years ago

coogle commented 4 years ago

Hello,

Great extension! Unfortunately I've discovered that the SVG file produced by it is buggy and incompatible in some situations with Adobe Illustrator.

Attached is the sketchup file that i'm trying to lay out for your reference. My process is to click on each component to open it, then click the face and lay it out for SVG. Once I've done all seven components I write the SVG file and open it in Illustrator. The result is the attached screenshot.

Any help you might be able to provide would be appreciated.

image

box.skp.zip

marvingreenberg commented 4 years ago

I did upload (just recently, version 2.3.0) a fix for a problem that would generate an incorrect view box which could cause strange side effects. What version are you using? I'll look at your model if I have a chance some time.

The attached picture does not look like that, completely. There are also sometimes issues if you do much editing of the generated 2D faces after "laying" them out. (I'm trying to imagine what could cause that "spike" - I'm assuming that is not intended...

coogle commented 4 years ago

Yeah that was my first thought and this is still happening in 2.3.0 - note that some SVG rendering engines (i.e. Chrome) have no problem with the SVG file but Illustrator clearly does.

Here is a screenshot of the same .svg from inkscape.

image

coogle commented 4 years ago

Looking into this further it seems part of the problem is that illustrator assumes some fill/stroke values that make it look totally broken. When I adjusted those I got the same shapes so that's good. But where I'm still encountering a problem now is in the upper-left piece shown in the last pic I sent -- see how on the upper left piece, upper-left corner, there is that weird white box? That supposed to be a cutout and there is supposed to be another one below it. See this part which is that layout:

It is happening in Inkscape, Chrome, and AI so very much an error in the face->SVG translation.

(note: I tried just exporting that one piece by itself and the error remained in the svg file)

image

marvingreenberg commented 4 years ago

If the SVG is generated "correctly" it shouldn't be distorted or have otherwise unexpected geometry. The current code is definitely not bug-free - I think I created several issues about different problems I have encountered. I just haven't had time to work on this (for quite a while).

A common problem I have observed occurs when the Sketchup model has unexpected features. In Sketchup, simply drawing a line to another line or arc BREAKS the line or arc, which can make the face you are exported have strange discontinuities. This (possibly because of bugs in the code or simply things that are ambiguous) will sometimes render the "loops" bounding faces in model in ways that seem incorrect.

OK, your picture above made it obvious that is exactly the issue.

ErrantLine

I loaded your model and verified your observed behavior when I generated that face.

Boxy-view

Note that the "rectangular" path has way too many points (more than 4). I deleted the errant line in your model and it generated cleanly. With that line, your model's geometry is ambiguous. Either my code or the way Sketchup reports the bounding face edges is causing the problem.

box2

Some users like to draw lines to make alignment easier. That is a bad practice because of Sketchup's tendency to break geometry whenever lines intersect. Instead draw "Guide" lines using the "tape measure tool" or align by using Sketchup's built-in alignment magic.

By the way, the attached views of the SVG are a piece of software I like a lot for looking at and editing SVG (https://boxy-svg.com/) It supports Windows, Mac, Linux, ChromeBooks(!) and is dirt cheap ($10) and (for me at least) much nicer the AD, AI -- its simpler and makes it very easy to see the SVG "structure". The one thing it is missing is a measurement tool, but I made a feature request and in the past the developer has been very responsive.

marvingreenberg commented 4 years ago

BTW, I'm intrigued. It seems tiny for a sanding down draft box (with a 30mm dust port?) A habitat box for a mouse?

coogle commented 4 years ago

Yes I actually ended up spotting the errant line between the cut-outs myself and fixed it last night! So it seems like this was more user-error on my part, than a bug on yours.

Regarding the SVG and breaking geometry and such I've never had a real problem with that. The one thing about using guides with sketchup for alignment vs. lines is you can't tell sketchup "Start at the middle point between two guides" which is a need I frequently find myself with. Other than errant line problems like this (which I certainly will be more aware of in the future), I've never noticed any particular complications when later manipulating or cutting the generated SVGs.

As for the actual purpose of this -- it's a prototype for a wall-mounted wine / spirit dispenser (using these):

https://smile.amazon.com/gp/product/B07881RXFW/

The intended use case is for a RV / mobile home where glass bottles are bulky / take up space and not ideal when bouncing down the road. FWIW this first iteration had issues -- but not a bad start.

marvingreenberg commented 4 years ago

So, there are some cases I'm aware of with circular arcs that are caused when you intersect a line with a circular arc. I forget the details -- you may be able to find some info in an outstanding issue. In those cases, I've seen that the SketchUp introduced break (one arc into two arcs) will cause the generated SVG to not be the correct two circular arcs. I have looked (months ago) but couldn't figure out the underlying problem.

Just something to have in mind.

On Wed, Jan 22, 2020, 11:35 AM John Coggeshall notifications@github.com wrote:

Yes I actually ended up spotting the errant line between the cut-outs myself and fixed it last night! So it seems like this was more user-error on my part, than a bug on yours.

Regarding the SVG and breaking geometry and such I've never had a real problem with that. The one thing about using guides with sketchup for alignment vs. lines is you can't tell sketchup "Start at the middle point between two guides" which is a need I frequently find myself with. Other than errant line problems like this (which I certainly will be more aware of in the future), I've never noticed any particular complications when later manipulating or cutting the generated SVGs.

As for the actual purpose of this -- it's a prototype for a wall-mounted wine / spirit dispenser (using these):

https://smile.amazon.com/gp/product/B07881RXFW/

The intended use case is for a RV / mobile home where glass bottles are bulky / take up space and not ideal when bouncing down the road. FWIW this first iteration had issues -- but not a bad start.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marvingreenberg/FaceSVG/issues/31?email_source=notifications&email_token=AABU5A2ACCKQGZHCXKWD7PLQ7BYUTA5CNFSM4KJ3CTGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJUHWEQ#issuecomment-577272594, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABU5A4PLQDJV3YSFA535WLQ7BYUTANCNFSM4KJ3CTGA .

coogle commented 4 years ago

Thanks! I will certainly do so. I don't know if it was just a bug in an earlier version but sometimes I've found I actually need to explode curves to get the svg to render correctly to cut as well.

marvingreenberg commented 4 years ago

Hmm. If you explode curves, I think that tuns them into polylines which is almost never desirable. Imagine you have a 180 degree circular arc. That renders as a single SVG circular arc. If you (as part of your drawing and construction, intersect it a few times with lines, now it may become multiple small arcs. Sketchup has some issues when the arc segments become small. So that can cause crashes. If you explode everything, then the arcs become 11 or 13 or some number of small line segments, not one arc. This makes the SO work harder, and makes the actual cut path only an approximation of what you actually want.

I really encourage you to try to play with the tape measure tool and guides. I'm glad you figured out this issue.