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

    [Plugin] Import ALL from Folder

    Scheduled Pinned Locked Moved Plugins
    77 Posts 20 Posters 65.2k Views 20 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

      @bitslapped said:

      I love this plugin. I think a nice addition would be an option to import onto a grid so components are easier to manage.
      Thanks TIG
      Try http://sketchucation.com/pluginstore?pln=components_grid
      This arranges installed components on a user chosen 'grid'...

      TIG

      1 Reply Last reply Reply Quote 0
      • Y Offline
        YoungOSG
        last edited by

        @tig said:

        @mattao987 said:

        ...I'd like to add an optionnal STAGE in your script.
        Once a file is imported, i'd like to create a new layer named by reference to the file name with a suffix.
        Let's say Wonka_Niv1
        Then, Group all the freshly imported items on this new layer.
        Then proceed to the next file...

        What file type are you importing?
        SKP and Others need to be treated differently...
        Obviously none of this 'Layering' stuff will ever work with imported 'Images' !!

        For non-SKP files:
        Provided there is at least one object already in the receiving-SKP, then all imported formats [other than a SKP] will already import as a component named after the file - e.g. "Wonka_Niv1.dwg".
        So after line#84:
        model.import(file,false)
        add these lines:
        unless File.extname(list[0]).downcase==".skp" ins=model.definitions[File.basename(file)].instances[0] ins.layer=model.layers.add(File.basename(file, ".*")) end#if
        Note: this uses the imported files 'basename' [e.g. "Wonka_Niv1"], to use the full name with say its '.dwg. suffix use ...add(File.basename(file)) instead

        For SKP imports you will need to edit another part of the code:
        after line#107:
        ins=model.active_entities.add_instance(defn,tr)
        add this:
        ins.layer=model.layers.add(name)
        This uses the imported SKP's name, without any '.skp' suffix [e.g. "Wonka_Niv1"] - but if you want to add one, then change ...add(name) to ...add(File.basename(file))

        This should do what you want... 😄

        after i use this plugins to add ade files,i can not see them!
        i can not understand why.
        any helps?

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

          You said 'ade', I guess you really meant '.DAE' ?
          They should import OK.
          Any error messages in the Ruby Console when try it ??

          TIG

          1 Reply Last reply Reply Quote 0
          • Y Offline
            YoungOSG
            last edited by

            @tig said:

            You said 'ade', I guess you really meant '.DAE' ?
            They should import OK.
            Any error messages in the Ruby Console when try it ??

            Yes! I mean *.dae files.
            I use your script.and add purge_unsed,export.
            However i need to handle thousands of files.Sketchup always crashes after export few files.
            I really don't know how to fix it.
            any helps?


            purge_multi_dae2 (2).rb

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

              I only use mac, but...

              you could, save each file to 'Trash', close it, then open a new for the next import?

              SU should then be starting fresh each time and you don't need to erase any entities?

              just a thought, I use the idea in a script...
              this is the an extract for Trash on a mac...

              def revert
                trash_copy = (File.expand_path("~/.Trash/" + "." + @orig.title + ".skp")).dup.freeze
                @orig.save(trash_copy)
                Sketchup.send_action("closeDocument;")
                Sketchup.send_action("newDocument;")
              end
              

              john

              learn from the mistakes of others, you may not live long enough to make them all yourself...

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

                @Young

                You code is overly complicated.
                It also has some odd working practices... 😕

                I am sure I have answered this same query elsewhere...
                See the @yuyuwhy posts...
                Is it you, but with a different user-name ??
                http://sketchucation.com/forums/viewtopic.php?p=554042#p554042

                This thread explains how to setup an empty model SKP - the order of purging IS important - yours is wrong !
                Do that BEFORE importing anything.

                It also suggests a sensible approach to the subsequent import, purge and export of each DAE in turn.
                If you enclose those actions within a ' model.start_operation(...)' block, BUT afterward each you ' model.abort_operation' it [NOT the usual ' model.commit_operation' it] then the imported data is simply forgotten, but the export is safe because the DAE file is now outside of the SKP's control... So there is no need to purge between each import/export at all.

                Recast your code thus...
                Make the host SKP empty.
                Process the list of DAE files in turn.
                Use a model.start_operation(...) block around each iterate step.
                Remember to use the model.abort_operation to undo the import etc, but leave the export intact.
                You should end up with an empty SKP and all of the DAE files processed.

                Incidentally, your code only works in v2015 as the UI folder selector is new in that version's API.

                TIG

                1 Reply Last reply Reply Quote 0
                • Y Offline
                  YoungOSG
                  last edited by

                  @driven said:

                  I only use mac, but...

                  you could, save each file to 'Trash', close it, then open a new for the next import?

                  SU should then be starting fresh each time and you don't need to erase any entities?

                  just a thought, I use the idea in a script...
                  this is the an extract for Trash on a mac...

                  def revert
                  >   trash_copy = (File.expand_path("~/.Trash/" + "." + @orig.title + ".skp")).dup.freeze
                  >   @orig.save(trash_copy)
                  >   Sketchup.send_action("closeDocument;")
                  >   Sketchup.send_action("newDocument;")
                  > end
                  

                  john

                  Thanks!
                  I tried it.It works fine on my PC,however it crashed on others.

                  1 Reply Last reply Reply Quote 0
                  • Rich O BrienR Offline
                    Rich O Brien Moderator
                    last edited by

                    This is splatting for me?

                    No console message. Just splat!

                    I try nuke my plugins older to isolate

                    Download the free D'oh Book for SketchUp 📖

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

                      @rich,

                      maybe your need to watch the tutorial?

                      john

                      learn from the mistakes of others, you may not live long enough to make them all yourself...

                      1 Reply Last reply Reply Quote 0
                      • Rich O BrienR Offline
                        Rich O Brien Moderator
                        last edited by

                        @john

                        hahahaha

                        even that didn't help...

                        I'm trying to import 126 faceme .skp then run components to grid.

                        I ain't getting past the import all part as yet.

                        SU2015 64bit Pro in case that helps?

                        Download the free D'oh Book for SketchUp 📖

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

                          seriously now...
                          I just tested it and had a splat as well, sent it to trimble...
                          I'll have a look a the report

                          john

                          learn from the mistakes of others, you may not live long enough to make them all yourself...

                          1 Reply Last reply Reply Quote 0
                          • Rich O BrienR Offline
                            Rich O Brien Moderator
                            last edited by

                            na na nana na

                            Download the free D'oh Book for SketchUp 📖

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

                              @rich line 101 delete puts re-save, restart...
                              worked for me

                              learn from the mistakes of others, you may not live long enough to make them all yourself...

                              1 Reply Last reply Reply Quote 0
                              • Rich O BrienR Offline
                                Rich O Brien Moderator
                                last edited by

                                nope! splat

                                Download the free D'oh Book for SketchUp 📖

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

                                  keep the puts deleted, but on line 106 add an new line UI.messagebox(name)
                                  try on a small number of skps first
                                  just to see if slowing it down helps...

                                  john

                                  learn from the mistakes of others, you may not live long enough to make them all yourself...

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

                                    That means you need to press OK 126 times !
                                    Rich, why not ZIP and email me those 126 SKPs, explain [clearly] what you want to do...

                                    TIG

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

                                      @Tig
                                      sorry, just trying to help out, thought you were at pub...

                                      it's failing with only two models to import...

                                      removing the puts helps sometimes,
                                      pre-saving the model helps sometimes,
                                      adding the UI.messagebox helps sometimes...

                                      but if I try a larger folder it bugsplats again...

                                      john

                                      learn from the mistakes of others, you may not live long enough to make them all yourself...

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

                                        OK, I'll check it out - not a bug reports for years, then three come at once...

                                        Maybe it needs updating...
                                        😕

                                        TIG

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

                                          I just revisited this Plugins code.
                                          As it was, it still worked fine for me on multiple SKP imports, but I have made some adjustments because the SKP import could now be more 'streamlined' > SUp v8...

                                          Here's the updated v1.4 RBZ in the PluginStore http://sketchucation.com/pluginstore?pln=import_from_folder

                                          Please try it and feedback.

                                          PS: Rich - you can email me the 126 SKPs in a ZIP if you like ?

                                          TIG

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

                                            bug splat on mac...
                                            there are some weird names, but I import them as a test folder for my icon maker plugin, and they were importing then failing last night...
                                            john
                                            full folder content

                                            .DS_Store
                                            .png
                                            ¨„¶®™_·_Ë‚„‡¢†´Æ¨.skp
                                            ¨„¶®™_·_™†°•´•¨.skp
                                            ¨„¶®™_·_™†≠®·‚‡Æ©.skp
                                            ¨„¶®™_·_™‡†·™Æ©.skp
                                            ¨„¶®™_·Æ_·‚•‚Á®™Æ¨_£•©£•‡†.skp
                                            ¨„¶®™_®_™‡Î·†.skp
                                            ¨„¶®™_≠†_´•·‚≠®Ê•.skp
                                            ¨„¶®™_߆_·‚ƴƨ.skp
                                            ¨„¶®™®_·_°ÆÁ™†¨®.skp
                                            ¨„¶®™®_¢_™Æ´Æ§Ê•.skp
                                            £Æ´Î©_¨„¶®™.skp
                                            file_names from folder.scpt
                                            filenames.txt
                                            Ø®‡Æ‚•Â≠®™.skp
                                            ØÆ¶†‡≠Ε_·Æ_·‚¢Æ´Æ¨_1.skp
                                            ØÆ¶†‡≠Ε_·Æ_·‚¢Æ´Æ¨_2.skp
                                            ØÆ¶†‡≠Ε_·Æ_·‚¢Æ´Æ¨_3.png
                                            ØÆ¶†‡≠Ε_·Æ_·‚¢Æ´Æ¨_3.skp
                                            ØÆ¶†‡≠Ω_·_‚ÆØÆ‡Æ¨.skp
                                            ØÆ¶†‡≠Ω_·_Æ£≠•‚„Ë®‚•´•¨.skp
                                            ØÆ¶†‡≠Ω_≠†_Ë•·‚•.skp
                                            ØÆ¶†‡≠Ω_1.skp
                                            ØÆ¶†‡≠Ω_2.skp
                                            ØÆ¶†‡≠Ω_3.skp
                                            ØÆ¶†‡≠Ω_3~.skp
                                            ru_aviator.skp
                                            ru_blueSanta.skp
                                            ru_garbageCollect.skp
                                            ru_glassman.skp
                                            ru_jackHammer_male.skp
                                            ru_jackHammer.skp
                                            ru_leafBlower.skp
                                            ru_plumBob.skp
                                            ru_surveyor.skp
                                            ru_welder.skp
                                            ru_wheelBarrow.skp
                                            site_logo.png
                                            welder.png
                                            welder.skp
                                            

                                            learn from the mistakes of others, you may not live long enough to make them all yourself...

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

                                            Advertisement