2D export to SVG
-
Thanks Chris, but I forgot to mention, that I use the free version of SU7. Is there, maybe, a Ruby script exporting to some other 2D vector format that could be used as a base for extending/modifying it to export SVG?
@chris fullmer said:
Have you tried the .eps format? It might be what your wanting.
Chris
best regards, deerwood
-
The free version does not allow .eps export?
Chris
-
I've always wanted to do an SVG exporter, but I've never had the right motivation.
-
Hi
I too was interested in this and in fact 'suggested' that Google SketchUp should support the SVG format for I/O. I then found somebody has done it for them/us:http://flightsofideas.com/
http://flightsofideas.com/?p=114#more-114
http://code.google.com/p/sketchup-svg-outline-plugin/Cheers,
- Diego -
-
Dear Chris, all,
@chris fullmer said:
The free version does not allow .eps export?
Nope (at least not in SU7), just pixel formats .bmp, .jpg, .tif, .png.
My main target application for SVG will be the OpenSource Inkscape to, for instance, make scalable images for wikipedia. Wikipedia (especially commons) prefers SVG over pixel formats, where appropriate (diagrams, schematics etc.) and has good support (thumbnails and intermediates are automatically converted to pixel images, the final image remains as SVG, open to be modified/extended by others).
Inkscape actually can import .pdf (but not .eps without hassles under XP) and preserves the vector format and e.g. grouping. Tested here with gnuplot generated .pdf files.
Thanks and best regards, deerwood
-
Dear dmatho/Diego,
thanks for your hints/links. But, as I had written in my initial message, I got (and inspected) these already ... though this plugin comes in handy, to lay out faces ready to be cut by laser, this is not, what I wanna have. And there is some (better?similar) plugin over at lumberjocks.com (or so). That one is excellent (with sophisticated WebDialogs and very good layout on boards etc). But both "miss" my point (they don't miss their point however).
@dmatho said:
I then found somebody has done it for them/us:
My point is, to have a SVG (2D vector format) essentially as seen from the SU camera.
best regards, deerwood
-
This can be done, but it would require a back face culling algorithm. I started such a project a few years ago (to takes the view the camera sees, and create a 2D plane of line work from that view. I had it working, but stopped when I realized I didn't now how to do the back face culling.
-
Hi Todd,
@unknownuser said:
This can be done, but it would require a back face culling algorithm. I started such a project a few years ago (to takes the view the camera sees, and create a 2D plane of line work from that view. I had it working, but stopped when I realized I didn't now how to do the back face culling.
Back face culling shouldn't be a big problem, see Wikipedia (de with formula). It reduces to testing the dot product of a face.normal vector and the camera.direction vector beeing + or - . Something like:
if camera.direction.dot(face.normal) > 0 ....
However I think the transformations of groups and component instances have to be taken into account, too. Would that motivate you, to continue with your script?
Another problem might be the view frustum culling/clipping ... for a first version I could live without that (e.g. having a rather small model and just moving the camera far enough away to see all of it).
And the last problem I see is the occlusion culling/clipping. Again I would be fine in a first version without that as long as the faces/edges are given out in correct back to front order.
Best regards, deerwood
-
-
I think I used the wrong term "back face culling". What I meant was I didn't know how to remove the faces in the model that that camera cannot see. (See, I don't even know the terminology!!)
As for the Wikipedia page... yeah right. Like I said, I knew when I needed to stop.
-
Dear Todd, all,
sorry for my late answer. This is a really great forum with so many helpful people around giving their knowledge away. I can't really keep up with all that in a timely manner .
@unknownuser said:
What I meant was I didn't know how to remove the faces in the model that that camera cannot see.
Yes, that "occlusion culling" gives me headaches too (my brain hurts). All algorithms I could find are assuming pixel output (Z-buffers etc). But for a vector output all these won't work.
In the extreme case neither entities nor lines nor points give a clear indication of what is in "in front" of each other ... because part of every entity might be "in front" of some entity and at the same time "behind" some other entity as seen from the camera:
After a discussion with an "expert" (actually my son, a student in CG) we came up with this basic idea:
- 3D space can be mapped to perspective 2D space using the correct matrix (see e.g. Matrix and Vector Manipulation. Search for "perspective").
- There is a way to do the 3D to 2D perspective mapping preserving a depth/Z coordinate as seen from the camera eye. May be, that mentioned matrix already does the job, I didn't test and my math edu/knowlege is poor.
- Now essentially beeing in 2D (camera) space: find any/all vectors/lines/edges that intersect. Calculate the 2D intersection points, then look up the distance from the eye and make use of it, by splitting up the lines. Same with faces.
Very short and far away from something working. Just an idea. Does my desription make sense?
Several problems had to be solved, amoung others a blind test for intersecting lines in the 2D camera space must be optimized somehow, to avoid (O2) behaviour (testing every line against every other line is just to expensive).
Could this idea be turned into a concept? If so, I/we can't believe to have found it before others. There MUST be some others having done that or better (e.g. the EPS/PDF export in SU Pro). Any pointers to vector algorithms are welcome.
Best regards, deerwood
-
What about an SVG printer driver?
At work I've used a EPS printer driver to save some work in EPS even though the application originally didn't support it. AutoCAD for example. I'd think that a SVG printer driver would work?
-
You can get a 2D vector PDF from SU by printing to a PDF printer with the "Use high-accuracy HLR" setting enabled. No textures or shadows, though. So if PDF can be directly imported into your application, this would possibly be the solution. The PDF file format is essentially the same as EPS, just compressed.
Anssi
-
@anssi said:
The PDF file format is essentially the same as EPS, just compressed.
hm? http://en.wikipedia.org/wiki/Encapsulated_PostScript http://en.wikipedia.org/wiki/Portable_Document_Format
Quite different I'd say. -
And SVG printer driver: http://www.svgmaker.com/
Haven't tried it yet though. But downloading trial now. -
@thomthom said:
@anssi said:
The PDF file format is essentially the same as EPS, just compressed.
hm? http://en.wikipedia.org/wiki/Encapsulated_PostScript http://en.wikipedia.org/wiki/Portable_Document_Format
Quite different I'd say.What I meant that both are based on the Postscript language.
When opened into Illustrator, the EPS and PDF exports from SU Pro are identical.A SVG printer would be interesting. The SVG Maker doesn't seem to support Vista.
Anssi
-
@anssi said:
What I meant that both are based on the Postscript language.
When opened into Illustrator, the EPS and PDF exports from SU Pro are identical.Ah, gotcha!
@anssi said:
A SVG printer would be interesting. The SVG Maker doesn't seem to support Vista.
Yea, just noticed. Doesn't work on either Vista 32bit nor Windows7 64bit.
An alternative is to use an eps or pdf printer and then use another application to convert to SVG. -
Dear all, especially thomthom and Anssi,
thanks a lot for your tips. Now I actually can generate SVG from SketchUp 7 free using only open source GPL tools! See attached ZIP with SVG file (I'm not allowed to upload SVG files directly). The SVG itself should be directly viewable in Safari, Firefox and Opera, in the latter two you also can zoom into the picture and see, that there is no quality loss, because it is really vector format.
I installed the PDFCreator printer driver and printed from within SU to a PDF file with the mentioned "Use high accuracy HLR" checked. This option is indeed available in the free SU 7 (and also documented to be available there). The PDF already looked very good and was zoomable to any extent without quality loss.
Then I startet InkScape and just imported the PDF, which took a second or so. I saved in InkScape SVG (plain SVG is possible too). And voila!
Note that this just was a quick check. The SVG file contains a lot of clippath elements, that I believe might not really be neccessary and blow the file size up much more as the few lines are worth it. But then I just worked with all default settings. I'll try and see if I can get rid of unneccessary clip pathes.
How nice! Thanks again, best regards, deerwood
-
Dear all,
I investigated a little bit further into that clippath thing. With the help of Inkscape and my text editor (yes, SVG actually is XML, so you can work on it with text tools including scripts ) I removed all these clippathes and their references, which turned the SVG filesize down from 180 KB to 18 KB. The file still is valid SVG ... but I lost all face coloring and was left with just the edges. See attachement.
So it turned out, that it has to do with shading/coloring the faces and seems to be caused by the PDF printing/export already and not beeing the fault of the InkScape import.
To shade/color a face a colored rectangle covering the 2D bounding box of the face in question is given out. As that opaque rectangle is much too big and would either cover other parts of the drawing or show up in the wrong places that rectangle then is clipped ... leading to overly complicated clipping pathes.
In plain SVG one instead just would define filled polygons exactly covering the visible face parts (in Z-Order behind the related edges of the face). I believe, this would reduce SVG file size essentially compared to the clipping way. And filled polygons are available in PostScript too and thus in EPS/PDF.
Please note, I am not complaining here in any way, just reporting what I've found, so others are aware of it.
What I'm not sure about is: is that strange way coloring faces is the way SketchUp works, maybe only when printing? Or is that caused by the used PDFCreator printer driver?
If you want to do me a favour, can someone with the SU 7 PRO version please be so kind and directly export the "four_matches.skp" (found in an earlier post) to PDF and hand it over to me? Thanks in advance. I'll then report here the results of my further exploration.
Remember, one of my main reasons for having SVG out of SU is supporting wikipedia commons (respecively open a way for others to better support commons) and they ask for SVG not only because of it's scalability, but also for SVG typically beeing much less in file size than pixel formats (for diagrams and schematic drawings, photos etc. still are better off in JPG).
Again, thanks a lot, this is such a friendly and helpful forum, I'm happy to have found it.
Best regards, deerwood
-
I've attached a .zip with two pdfs. One is from SU's export function, and one is made using Adobe's PDF printer.
(p.s. You added the .skb, not the .skp file... )
Advertisement