• Login
sketchucation logo sketchucation
  • Login
πŸ”Œ Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

2D export to SVG

Scheduled Pinned Locked Moved Developers' Forum
31 Posts 6 Posters 6.6k Views 6 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    deerwood
    last edited by 29 Jan 2009, 15:14

    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

    1 Reply Last reply Reply Quote 0
    • C Offline
      Chris Fullmer
      last edited by 29 Jan 2009, 15:24

      The free version does not allow .eps export?

      Chris

      Lately you've been tan, suspicious for the winter.
      All my Plugins I've written

      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by 29 Jan 2009, 17:44

        I've always wanted to do an SVG exporter, but I've never had the right motivation.

        1 Reply Last reply Reply Quote 0
        • D Offline
          dmatho
          last edited by 29 Jan 2009, 19:42

          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 -
          1 Reply Last reply Reply Quote 0
          • D Offline
            deerwood
            last edited by 30 Jan 2009, 03:26

            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

            1 Reply Last reply Reply Quote 0
            • D Offline
              deerwood
              last edited by 30 Jan 2009, 03:52

              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

              1 Reply Last reply Reply Quote 0
              • T Offline
                todd burch
                last edited by 30 Jan 2009, 10:30

                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.

                1 Reply Last reply Reply Quote 0
                • D Offline
                  deerwood
                  last edited by 30 Jan 2009, 19:33

                  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

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    deerwood
                    last edited by 30 Jan 2009, 19:45

                    Hi all,

                    I found back the link to the Lumberjocks CutList 4.0 Ruby script.

                    best regards, deerwood

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      todd burch
                      last edited by 30 Jan 2009, 19:52

                      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.

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        deerwood
                        last edited by 8 Feb 2009, 07:31

                        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:
                        four_matches.png

                        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


                        ZIP with just the SKP

                        1 Reply Last reply Reply Quote 0
                        • thomthomT Offline
                          thomthom
                          last edited by 8 Feb 2009, 09:57

                          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?

                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                          List of my plugins and link to the CookieWare fund

                          1 Reply Last reply Reply Quote 0
                          • AnssiA Offline
                            Anssi
                            last edited by 8 Feb 2009, 12:34

                            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

                            securi adversus homines, securi adversus deos rem difficillimam adsecuti sunt, ut illis ne voto quidem opus esset

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by 8 Feb 2009, 13:07

                              @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.

                              Thomas Thomassen β€” SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by 8 Feb 2009, 13:09

                                And SVG printer driver: http://www.svgmaker.com/
                                Haven't tried it yet though. But downloading trial now.

                                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                List of my plugins and link to the CookieWare fund

                                1 Reply Last reply Reply Quote 0
                                • AnssiA Offline
                                  Anssi
                                  last edited by 8 Feb 2009, 22:11

                                  @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

                                  securi adversus homines, securi adversus deos rem difficillimam adsecuti sunt, ut illis ne voto quidem opus esset

                                  1 Reply Last reply Reply Quote 0
                                  • thomthomT Offline
                                    thomthom
                                    last edited by 8 Feb 2009, 22:34

                                    @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.

                                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                    List of my plugins and link to the CookieWare fund

                                    1 Reply Last reply Reply Quote 0
                                    • D Offline
                                      deerwood
                                      last edited by 8 Feb 2009, 23:44

                                      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


                                      Four matches as SVG

                                      1 Reply Last reply Reply Quote 0
                                      • D Offline
                                        deerwood
                                        last edited by 9 Feb 2009, 02:55

                                        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


                                        four_matches_clean.zip

                                        1 Reply Last reply Reply Quote 0
                                        • thomthomT Offline
                                          thomthom
                                          last edited by 9 Feb 2009, 08:25

                                          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... πŸ˜‰ )


                                          matches.zip

                                          Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                          List of my plugins and link to the CookieWare fund

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 1 / 2
                                          • First post
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement