• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

[Plugin]export_by_layer.rb

Scheduled Pinned Locked Moved Plugins
12 Posts 9 Posters 11.5k Views
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.
  • T Offline
    TIG Moderator
    last edited by 10 Sept 2009, 16:35

    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
    • T Offline
      thomthom
      last edited by 11 Sept 2009, 10:30

      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 11 Sept 2009, 11:54

        @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
        • T Offline
          TIG Moderator
          last edited by 11 Sept 2009, 13:09

          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 15 Jan 2010, 20:03

            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 23 Apr 2010, 10:46

              @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
              • T Offline
                TIG Moderator
                last edited by 23 Apr 2010, 11:18

                @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 29 Sept 2012, 19:20

                  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 2 Oct 2012, 12:35

                    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 27 Mar 2015, 07:13

                      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 18 Sept 2015, 12:39

                        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 2 Nov 2017, 11:30

                          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