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

    Is this possible? [code] batch export

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 7 Posters 2.6k Views 7 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.
    • R Offline
      robmoors
      last edited by

      I was wondering is there a ruby out there which does this?

      I have to export my 3D models in several 3D extensions. Its a time consuming thing to do by hand if youve got to export 10 models in 5 different formats each time. So I was wondering can this be automated with a ruby?

      Something like this:

      • Open model
      • Click Ruby
      • Tick the 3D extensions you want your model exported in
      • Select a folder all these exports go into
      • Press okay and supress any file name errors by automatically accepting them (3ds and a few more replace the spaces between words with underscores and asks if this is okay)
      • SU starts exporting each 3D extension one by one with just that one click

      Is this possible, or is something like this out there? It would mean the world to me.

      Any help in this matter would be greatly appreciated!!

      Rob Moors
      Architecture Student

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Rob,

        I think it's possible, at least most of it. What extensions should be available as options?

        The core functionality is simple. If you can make this work, the rest is grunt work. You can copy and paste it right into the Ruby Console to test it.

        
        %w(dxf kmz fbx obj).each {|ext| Sketchup.active_model.export("/testmodel.#{ext}",false)}
        
        

        This files should be create on 😄 on a Windows machine, and the / folder on a Mac (I assume.) I don't have the Pro exporters and so can't test them.

        Hi

        1 Reply Last reply Reply Quote 0
        • Dave RD Offline
          Dave R
          last edited by

          Jim, I tried your line of code and it seemed to work. There was a stop after the DXF export for user acknowledgement that the export had completed. I imagine Rob would like even that to be automated if it could be.

          Etaoin Shrdlu

          %

          (THERE'S NO PLACE LIKE)

          G28 X0.0 Y0.0 Z0.0

          M30

          %

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            @dave r said:

            Jim, I tried your line of code and it seemed to work. There was a stop after the DXF export for user acknowledgement that the export had completed. I imagine Rob would like even that to be automated if it could be.

            That's promising. I edited the code snippet to add an explicit "false" to the export. If this does not make the DXF acknowledgment dialog go away, I don't think there is anything that can be done about it.

            Hi

            1 Reply Last reply Reply Quote 0
            • T Offline
              todd burch
              last edited by

              That specifically is a bug that's been reported already. (the dxf / false thingy)

              Todd

              1 Reply Last reply Reply Quote 0
              • R Offline
                robmoors
                last edited by

                Hey guys, thanks for your help so fast!

                I want to export to

                .3ds
                .dwg
                .dae
                .obj

                I would be willing to bash my return button a few times to make those pop ups go away. Is it possible that way?

                Keep in my I have no idea how ruby's work, so that piece of code looks really fancy to me but what to do with it is beyond me. 😛

                Rob Moors
                Architecture Student

                1 Reply Last reply Reply Quote 0
                • R Offline
                  RickW
                  last edited by

                  Using a dot-slash ( ./ ) puts the export files in the same folder as the original file (assumes the file has been saved somewhere), which might be more convenient.

                  Regardless, nice one-line coding 😄 Too bad this wasn't issued specifically as a ruby challenge item...

                  RickW
                  [www.smustard.com](http://www.smustard.com)

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    RickW
                    last edited by

                    Rob,

                    To export to the types you specified, just change the stuff in parentheses after the %w at the beginning - something like

                    %w(3ds dwg dae obj)......

                    and leave the rest of the code intact.

                    RickW
                    [www.smustard.com](http://www.smustard.com)

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      robmoors
                      last edited by

                      And I enter the code into the ruby entry console? or could I form it into a nice button?

                      Rob Moors
                      Architecture Student

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        todd burch
                        last edited by

                        Make 2 nice buttons and post them here. a 16X16 pixel and a 32X32 pixel. Someone will do it. 😉
                        Todd

                        1 Reply Last reply Reply Quote 0
                        • R Offline
                          robmoors
                          last edited by

                          Here you go 2 quick png's

                          http://www.sketchucation.com/forums/scf/sas/Ruby/Big32.png

                          http://www.sketchucation.com/forums/scf/sas/Ruby/Small16.png

                          Rob Moors
                          Architecture Student

                          1 Reply Last reply Reply Quote 0
                          • R Offline
                            robmoors
                            last edited by

                            Pwetty Pwease someone?

                            Rob Moors
                            Architecture Student

                            1 Reply Last reply Reply Quote 0
                            • bradB Offline
                              brad
                              last edited by

                              Hey Rob,

                              I just continued where Jim and Rick left off.

                              Put the contents of what is in the attached .zip into you plugins directory and restart SketchUp.

                              You'll see your icon that you made. Open a model click on the tool bar icon. The model will be exported to c:\ with the models name i.e. whatever the name says in the Title bar. I also gave the icon a tool tip and the status bar text.

                              Let me know if that works. This is a first draft and I'm sure it could be better.

                              BTW the defect Todd was talking about "not suppressing the results dialog after dwg export" is fixed and will be in the next version of SketchUp.

                              Hope this helps, I hope it doesn't suck....it good to breath clean air 💚

                              301 Moved Permanently

                              favicon

                              (www.sketchucation.com)

                              Brad
                              SketchUp QA

                              1 Reply Last reply Reply Quote 0
                              • R Offline
                                robmoors
                                last edited by

                                Thanks alot Brad!
                                This will save me and the guys over at FF quite a bit of time!

                                If anyone is interested in advancing this ruby,
                                A window in which you can tick the exports and specify their file names and their location would be awesome.

                                But for now this works perfectly! It indeed is nice to breath clean air Brad 😉 !

                                Rob Moors
                                Architecture Student

                                1 Reply Last reply Reply Quote 0
                                • boofredlayB Offline
                                  boofredlay
                                  last edited by

                                  @robmoors said:

                                  If anyone is interested in advancing this ruby, a window in which you can tick the exports and specify their file names and their location would be awesome.

                                  Any progress on this one?
                                  I used it the other day and all the files showed up with no name, just a .dwg .obj etc...
                                  I would welcome a more refined script.

                                  Thanks.

                                  http://www.coroflot.com/boofredlay

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

                                  Advertisement