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

    [Plugin]export_by_layer.rb

    Scheduled Pinned Locked Moved Plugins
    12 Posts 9 Posters 11.5k Views 9 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      Usage: export_by_layer(type)
      Typed in Ruby Console or another script...
      Exports everything in the active Model into a set of files 'by layer',
      put in the Model's folder named with the 'layer_name' as a suffix.
      The argument 'type' sets the file export type...
      e.g. type = 'obj' [as a string inside '' or ""] other types possible e.g. 'dxf'
      Faces with their Edges on another Layer take those Edges with them...
      For example: export_by_layer('obj')
      Put in Plugins Folder...PayPalButton

      TIG

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        There's API methods to export to different filetypes?

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

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

          @thomthom said:

          There's API methods to export to different filetypes?

          Sort of - the type is taken from the filename extension in Model.export. There is no way to specify any options, as far as I know.

          Hi

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            The only option is the 2nd argument true/false which either pops up a report on what's been exported or not. The export method decodes what type of file to export from the file suffix - e.g. .obj, .dwg, .dxf... I think that it takes the settings as given in the manual export dialog options... These can't be 'scripted' [unless on a PC you use WinScript and change the options by sending key-strokes...]

            By default the whole model is exported - my work around is to export by layer - it temporarily erases everything else that's on other layers (except Layer0), then exports what's left and then undoes the erase so we are back as we started...

            The idea can also be used to export a selection by temporarily grouping it and erasing everything else, then exporting what's left, then undo the erase and explode the group... I'll write a quick version...
            EDIT: it's here... http://forums.sketchucation.com/viewtopic.php?p=183756#p183756

            TIG

            1 Reply Last reply Reply Quote 0
            • X Offline
              xiobus
              last edited by

              Hey tig that code doesn't 100% work for me when i use instead of export the save skp method sometimes extra stuff is deleted, seems to be an issue with groups not being handled in the code? And also when no groups are used rogue bits from other layers are included. I'll take a look at the code again and see if its handling groups or not.

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

                @tig said:

                Usage: export_by_layer(type)
                Typed in Ruby Console or another script...
                Exports everything in the active Model into a set of files 'by layer',
                put in the Model's folder named with the 'layer_name' as a suffix.
                The argument 'type' sets the file export type...
                e.g. type = 'obj' [as a string inside '' or ""] other types possible e.g. 'dxf'
                Faces with their Edges on another Layer take those Edges with them...
                For example: export_by_layer('obj')
                [attachment=0:144rdr3z]<!-- ia0 -->export_by_layer.rb<!-- ia0 -->[/attachment:144rdr3z]

                Firstly, thanks for your work in this problem.
                I wonder how it works. I don't see the icon or something like that in Sketchup menus or everywhere to active it. Could you give some tutorials step-by-step?
                Secondly, I see there are few choices when exporting sketchup into cad while still keeping layers alive, especially when export sections.
                Any help for this thing?

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  @jackalvn said:

                  @tig said:

                  Usage: export_by_layer(type)
                  Typed in Ruby Console or another script...
                  Exports everything in the active Model into a set of files 'by layer',
                  put in the Model's folder named with the 'layer_name' as a suffix.
                  The argument 'type' sets the file export type...
                  e.g. type = 'obj' [as a string inside '' or ""] other types possible e.g. 'dxf'
                  Faces with their Edges on another Layer take those Edges with them...
                  For example: export_by_layer('obj')
                  [attachment=0:334crvrl]<!-- ia0 -->export_by_layer.rb<!-- ia0 -->[/attachment:334crvrl]

                  Firstly, thanks for your work in this problem.
                  I wonder how it works. I don't see the icon or something like that in Sketchup menus or everywhere to active it. Could you give some tutorials step-by-step?
                  Secondly, I see there are few choices when exporting Sketchup into CAD while still keeping layers alive, especially when export sections.
                  Any help for this thing?

                  You sort of answered your own question in the quoted text. 😒
                  Usage: export_by_layer(type) Typed in Ruby Console or another script...
                  You can write a script to run it with a menu item etc BUT the simplest way is to open Window > Ruby Console and type in export_by_layer(type) + <enter>
                  Exports everything in the active Model into a set of files 'by layer',
                  put in the Model's folder named with the 'layer_name' as a suffix.
                  The argument 'type' sets the file export type...
                  e.g. if type = 'obj' [as a string inside '' or ""] other types possible e.g. 'dxf', 'dwg'
                  Faces with their Edges on another Layer take those Edges with them...
                  For examples: export_by_layer('obj') or export_by_layer('dwg')
                  The files produced are named 'ModelName__Layer_Layer0.dwg', 'ModelName__Layer_DOORS.dwg', 'ModelName__Layer_WALLS.dwg' etc....
                  Exporting 3D keeps everything Layered in CAD, in 2D it does not work the same way...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • G Offline
                    GooUser
                    last edited by

                    Hello,

                    I would like to export individually layers as PNG ou JPG files, but this plugin not works when i tried with "export_by_layer "png".

                    Can you help me to understand or to propose me another solution if it exists?


                    Bonjour, j'aimerai exporter des calques Sketchup individuellement en tant qu'images PNG ou autres formats images. J'ai essayé ces plugins export_by layer et export_by_selection sans succès.Ils n'exportent pas les fichiers sous le format image. Après je ne sais pas si je m'y prends mal mais j'ai constaté qu'il exporte bien en format 3D comme OBJ. Donc je suppose qu'il ne fonctionne pas pour la 2D seulement ?

                    Auriez-vous une solution à me propser pour exporter en lot en format images, car exporter un par un est très long pour un modèle avec beaucoup de calques.

                    merci de votre aide.

                    1 Reply Last reply Reply Quote 0
                    • G Offline
                      GooUser
                      last edited by

                      How to export as png o jpg files with this plugin, please ?

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        arain_89
                        last edited by

                        hi.
                        what should i do if i want to export a section from my model in 2D dwg with layers?

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

                          to export 2d graphics by layer you can exchange line 72
                          model.export(modelpath+"/"+modeltitle+"_Layer"+layername+"."+type,false)### exporter

                          by:
                          view = model.active_view
                          view.write_image (modelpath+"/"+modeltitle+"_Layer"+layername+"."+type)

                          this will dissable all 3D-Export possibilities and you have to use valid Image file formats liek 'jpg' as type.

                          1 Reply Last reply Reply Quote 0
                          • C Offline
                            cox
                            last edited by

                            Hi everyone,

                            Is the script supposed to work with 'skp' extension too?

                            I am on Skethup Make 17, *dae and *kmz are exporting correctly but is there any way to save a native skp file by layer? The console reports: X files exported by layer, as 'skp'
                            altough there is nothing in the model folder.

                            Thanks a lot for the help!

                            Andrea

                            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