sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    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

      Dear all,

      I'm a newbie regarding Ruby and SketchUp (the API).

      I'm surprised that (after googling several days) I could not find any plugin spitting out essentially the same as the built in image exports (*.png/jpg ...) to SVG (Scalable Vector Graphics). A view onto the model, as seen from the camera, not in some (unscalable, not really antialized) pixel format, but instead in a common vector format, scalable and wide spread.

      I'm not after exploding/laying out some SU faces/edges optimized e.g. to do woodwork (I got these plugins already) and get a layout/material calculation.

      I just want to see my current SU view exported to SVG, respecting as much of the SU settings (e.g. visible layers, hiddden entities etc).

      Any hints?

      best regards, deerwood

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        Have you tried the .eps format? It might be what your wanting.

        Chris

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

        1 Reply Last reply Reply Quote 0
        • D Offline
          deerwood
          last edited by

          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
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            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

              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

                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

                  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

                    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

                      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

                        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

                          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

                            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

                              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

                                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

                                  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

                                    @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

                                      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

                                        @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

                                          @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

                                            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
                                            • 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