sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    Mac User? | Join the Rayscaper Beta for Mac Learn More

    Reload component script - anyone have one

    Scheduled Pinned Locked Moved Developers' Forum
    21 Posts 13 Posters 4.7k Views 13 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.
    • thomthomT
      thomthom
      last edited by

      Moved this topic to the Developer section of the forum.

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

      1 Reply Last reply
      Reply Quote 0
      • S
        sahi
        last edited by

        It is my experiment.
        Prompt me if that not so.

        1. we choose a file (this will be a folder )
        2. We enter the name of component
        3. we choose a component in which and will replace

        Attention!!!! Attention!!!! Attention!!!! before the use backup folder
        menu "Plugins >> reload_component"
        reload_component2.rb

        1 Reply Last reply
        Reply Quote 0
        • S
          SLOf1Fan
          last edited by

          For some reason I have recently found that right-clicking a residence model in my site model to update the revised component does not work. I get the usual pop-up stating the component has been added and asks if I'd like to replace, however when I click yes, nothing happens. It used to open the file folder so I can select the replacement folder. Please help.

          1 Reply Last reply
          Reply Quote 0
          • T
            Technical Ben
            last edited by

            Sorry to post in an old thread. But I'm looking for something similar to this.
            Just a hobby project, but I would really like a tool that checked for updates to components for me.

            So, I have a large file separated into separate components, these are save in a folder (such as Floor 1, Floor 2, Floor 3 etc). These are constructed into one big model (Such as "House"). I would like a script that automatically loaded up the components from file, when I opened the main project. I thought Sketchup did this automatically, but I have to click "reload" and each component separately. 😞

            1 Reply Last reply
            Reply Quote 0
            • honoluludesktopH
              honoluludesktop
              last edited by

              Select Window > components, right click the component you want to change in the component's window, then "select instances", again right click the component in the component's window, and "reload", "yes", and find the .skp you want.

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

                My old XrefManager does do this BUT you need to have added the items as an 'Xref'... It is long overdue an update, but does list components that have changed externally and then allows you to reload them...

                TIG

                1 Reply Last reply
                Reply Quote 0
                • T
                  Technical Ben
                  last edited by

                  Thanks honoluludesktop.
                  I'll have to do that, and force myself not to amend objects in the wrong file.

                  1 Reply Last reply
                  Reply Quote 0
                  • B
                    BigAl
                    last edited by

                    I'm using Thom Thom's lines of code below to batch replace a series of proxy components with hi-res versions.
                    newDef = model.definitions.load(path_to_new_component)
                    oldDef = model.definitions['definitionName']
                    oldDef.instances.each { |old_inst|
                    t = old_inst.transformation
                    ents = old_inst.parent.entities
                    ents.add_instance(newDef, t)
                    old_inst.erase!
                    }
                    To speed this process up I'd like to add a conditional test before this code such that the code to replace Component A with Component B only runs if Component A already exists within the model. Otherwise skip to the next component in the list.
                    Does such code or similar already exist somewhere?
                    Any help greatly appreciated.

                    1 Reply Last reply
                    Reply Quote 0
                    • Dan RathbunD
                      Dan Rathbun
                      last edited by

                      It looks like it already does that.

                      Meaning ComponentA's defintion's instances collection is iterated, and the statements within the curly delimited block are run if the collection has any references pointing at instances that have been placed within the model.

                      IF the instances collection is empty, then the iteration loop is exited without running the block.

                      ❓

                      I'm not here much anymore.

                      1 Reply Last reply
                      Reply Quote 0
                      • B
                        BigAl
                        last edited by

                        Thanks Dan,
                        I hadn't noticed that behaviour before. Initially being only interested in getting a couple of components into the model it wasn't an issue and I would always have the proxies in the model to check that the swap worked ok.
                        Looking at this again it looks like the components are all loaded into the file in turn. When I repeat ThomThom's text as below only Comp4 gets deleted if not required to replace comp3 (being the last to be loaded). Comp2 get left behind.

                        newDef = model.definitions.load("J:/Comp2.skp")
                        oldDef = model.definitions['Comp1']
                        oldDef.instances.each{|old_inst|old_inst.definition=newDef
                        t = old_inst.transformation
                        ents = old_inst.parent.entities
                        ents.add_instance(newDef, t)
                        old_inst.erase!
                        }
                        newDef = model.definitions.load("J:/Comp4.skp")
                        oldDef = model.definitions['Comp3']
                        oldDef.instances.each{|old_inst|old_inst.definition=newDef
                        t = old_inst.transformation
                        ents = old_inst.parent.entities
                        ents.add_instance(newDef, t)
                        old_inst.erase!
                        }

                        1 Reply Last reply
                        Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better πŸ’—

                        Register Login
                        • 1
                        • 2
                        • 2 / 2
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement