sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Save Components as separate files

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    15 Posts 7 Posters 6.3k 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.
    • V Offline
      VandB
      last edited by

      Hello Sketchup,

      I have this complex model with tons of Components. I'm looking for a way to export or save all selected components as separate file. This way I will end up with maybe 1K of SKP files.
      All separate files must have there own original coordinate as set in Masterfile.

      I know I can 'save as' within the Outliner or Components manager. But that's not enough because that will take me a whole day.

      Looking forward to the answer.

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

        Being an advanced user, I suppose you've already thought about using Save as a local collection from the Components window and rejected that option. Why wouldn't that work for you?
        Screenshot - 2_11_2015 , 4_21_17 AM.png

        No matter how you save components, they don't keep their coordinates from the original master file. If they are geo-located, though, they would maintain that coordinate setting so they could be imported into a new geo-located model and wind up in the correct location.

        Etaoin Shrdlu

        %

        (THERE'S NO PLACE LIKE)

        G28 X0.0 Y0.0 Z0.0

        M30

        %

        1 Reply Last reply Reply Quote 0
        • V Offline
          VandB
          last edited by

          I'm aware of that option. Although this way all Components will be saved at Origin.

          So here is what I want to do: I want to animate each Component or Group in Lumion. Therefor it needs to import not the whole model but each separate component. Something like an exploded view (Disassembled to Assembled).
          So each wall, door, ceiling, etc, needs to be saved separately with the coordinate of its master file. This is needed because this way I can Arrange (by coordinate) all separate files so it becomes one building again.

          Never used the geo-located option thou.

          1 Reply Last reply Reply Quote 0
          • V Offline
            VandB
            last edited by

            Something like: https://extensions.sketchup.com/en/content/cg-adjust-n-export
            But this script doesn't work perfectly...

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

              Geo location is intended for whole buildings or other structures whose location on the earth is important. You would generally get the geo-location info from Google Maps or set a location in Model Info. Maybe that would work for your application.

              What doesn't work "perfectly" with that plugin?

              Etaoin Shrdlu

              %

              (THERE'S NO PLACE LIKE)

              G28 X0.0 Y0.0 Z0.0

              M30

              %

              1 Reply Last reply Reply Quote 0
              • V Offline
                VandB
                last edited by

                Thanks for your information.

                That Plugin isn't perfect because it only saves unique components. Not copies of it. So when having a building with 10 copies of a door it only exports 1 of them.
                And for some reason the export option doesn't pop-up when selecting multiple components with subcomponents in it.

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

                  I understand about the nested components. Perhaps the author could be asked to revise the plugin to handle nested components.

                  As for the 10 copies of your door component, no matter how many copies (instances) there are of it in your model, there's still only one component definition to save. The only way to save all 10 copies of the door would be to make each one unique from the rest. You'd want to do that anyway if you were going to reset their origins to the model origin. The component origin and axis alignment is part of the definition so every door would need a different definition.

                  Etaoin Shrdlu

                  %

                  (THERE'S NO PLACE LIKE)

                  G28 X0.0 Y0.0 Z0.0

                  M30

                  %

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

                    You can export all component definitions with a simple one-liner.
                    Of course it could be made more sophisticated, but here it is...

                    m=Sketchup.active_model;puts p=File.dirname(m.path);m.definitions.each{|d|next if d.group? || d.image?;puts n=d.name.gsub(/[\/\\;<>"|\*\?]/,'_')+'.skp';d.save_as(File.join(p,n))};puts
                    

                    Copy+Paste it into the Ruby Console + <enter>.
                    It processes every Component Definition [even nested ones] in the Model, it skips Groups and Images.
                    It prints the path to the saved files [the Model's path folder].
                    It prints out the names of the individual SKP files as it processes them...
                    Note how any characters that might be acceptable in a component's name, but which will be unacceptable in a file-path [e.g. ':'] are replaced by a '_'...

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • MrMitchellM Offline
                      MrMitchell
                      last edited by

                      @tig said:

                      You can export all component definitions with a simple one-liner.
                      Of course it could be made more sophisticated, but here it is...

                      m=Sketchup.active_model;puts p=File.dirname(m.path);m.definitions.each{|d|next if d.group? || d.image?;puts n=d.name.gsub(/[\/\\;<>"|\*\?]/,'_')+'.skp';d.save_as(File.join(p,n))};puts
                      

                      Copy+Paste it into the Ruby Console + <enter>.

                      It processes every Component Definition [even nested ones] in the Model, it skips Groups and Images.
                      It prints the path to the saved files [the Model's path folder].
                      It prints out the names of the individual SKP files as it processes them...
                      Note how any characters that might be acceptable in a component's name, but which will be unacceptable in a file-path [e.g. ':'] are replaced by a '_'...

                      Can you modify this to specify a specific version of SKP to save as (I think it may be a workaround for the lvl to skp?)

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

                        In this example code, definition.save(path) can have no argument to set the SKP's version.
                        But in model.save(path, version) there is [at least in the newer versions of SketchUp]
                        To save all definitions as separate SKPs you can make a folder, save the definitions into it in turn...
                        Then you can process the SKPs in that folder, you'd need to open each of then and save, resetting the version...

                        Alternatively, in a set of start_operation...abort_operation... blocks [iterated one per definition] - so that the changes to the model are not remembered - you could .clear! the model.entities, then place an instance of that component at the origin, zoom to it, explode the instance [and any nested containers too?], then purge unused components, layers and materials, then save the model, specifying the version desired, then abort_operation to reset the model... repeat until all definitions have SKPs in a subfolder. The final abort should reset back to the starting set up.

                        This is very similar to my recently reissued 'layer exporter', but easier to control and use ??

                        TIG

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

                          @MrMitchell

                          I'll PM you an RBZ version of TIG-export_SKP_by_definition v1.0 for you to test.

                          If it's OK then I can publish it in the PluginStore...

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • MrMitchellM Offline
                            MrMitchell
                            last edited by

                            Great, I should have PM'd you my feedback on the TIG-export_SKP_by_definition, let me know if it didn't go through and I'll post it here.

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

                              @tig said:

                              @MrMitchell

                              I'll PM you an RBZ version of TIG-export_SKP_by_definition v1.0 for you to test.

                              If it's OK then I can publish it in the PluginStore...

                              TIG, did you ever upload this onto the Extension Warehouse?

                              1 Reply Last reply Reply Quote 0
                              • jujuJ Offline
                                juju
                                last edited by

                                @chrismichaelgentile said:

                                TIG, did you ever upload this onto the Extension Warehouse?

                                I don't think I've ever seen any of TIG's plugins / extensions on the EW, he has them here in the SketchUcation PluginStore.

                                Save the Earth, it's the only planet with chocolate.

                                1 Reply Last reply Reply Quote 0
                                • O Offline
                                  ogabifavour @MrMitchell
                                  last edited by

                                  @MrMitc hello, pls can you modify this to include groups. i want to make an exploded animation of my model. thanks

                                  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