• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Globally select all groups in model?

Scheduled Pinned Locked Moved SketchUp Discussions
sketchup
37 Posts 4 Posters 895 Views 4 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.
  • T Offline
    thomthom
    last edited by 3 Jun 2013, 10:13

    Try this quick mashup.


    tt_g2c.rbz

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

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 3 Jun 2013, 10:13

      @fullyfledgeded said:

      Oh & its kinda imperative that the code can globally locate them all too, so i don't have to do that manually.

      "Globally locate"?

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

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 3 Jun 2013, 11:00

        TT posted his ahead of me, perhaps it is better...

        So to put this another way...
        You want to find all groups in the active_entities collection that are duplicate copies.
        Then to make the first one into a component-instance, and then to replace all of the other copies with instances of that new component...
        Try this one-liner in the Ruby Console...

        m=Sketchup.active_model;m.start_operation('g2c');m.active_entities.grep(Sketchup;;Group).each{|g|next unless g.valid?;s=g.entities.parent.instances; next unless s[1]; n=s[0].name;d=s[0].to_component.definition;d.name=n if n!='';s[1..-1].each{|e|i=e.to_component;b=i.definition;i.definition=d;b.entities.clear!;};};m.commit_operation;
        

        It's one step undoable.
        It processes duplicated groups in the active_entities.
        It names the new component after the group, but if that's '', then it is called 'Group#123' etc...

        TIG

        1 Reply Last reply Reply Quote 0
        • F Offline
          fullyfledgeded
          last edited by 3 Jun 2013, 17:09

          TIG, your code works perfectly, provided groups that are duplicate copies to be found, are in the active selection set. I have attachedTIG code test.skp in case this doesn't make sense.

          In the outliner, Please select the contents of "test 1: in active selection set" & run your code. Then repeat for "test 2: not in active selection set".

          I need the script to find them all for me, as there are hundreds nested deep within the outliner, which i hope explains why I said "globally locate".

          thomthom's code achieves this, but makes each duplicate group copy a unique component , so a synergy of your 2 codes would be perfect, but this is probably asking a lot.

          thomthom, i installed your mashup with your quick install plugin, but i cant find it? I've searched "g2c" in the launchup plugin too.

          Cheers

          1 Reply Last reply Reply Quote 0
          • T Offline
            thomthom
            last edited by 3 Jun 2013, 17:39

            Under the Plugins menu. "Convert Groups to Components"

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

            1 Reply Last reply Reply Quote 0
            • F Offline
              fullyfledgeded
              last edited by 3 Jun 2013, 18:14

              cheers thomthom, i confused it with http://sketchucation.com/forums/viewtopic.php?t=29462

              worked perfectly, my only concern is that I undid it, to check the stats via model info & it bugsplatted. So I have saved a new copy to be safe.

              I put enough in your cookie jar for two beers in the uk, so you can atleast afford one in Norway.. damm expensive

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 3 Jun 2013, 19:19

                BugSplat? o_O Can you reproduce it? Got a test model?

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

                1 Reply Last reply Reply Quote 0
                • F Offline
                  fullyfledgeded
                  last edited by 3 Jun 2013, 19:40

                  http://sketchucation.com/forums/download/file.php?id=106847

                  run your sript > edit - undo = splat

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 3 Jun 2013, 20:18

                    Huh! I see the crash too. This is not good. 😞

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

                    1 Reply Last reply Reply Quote 0
                    • F Offline
                      fullyfledgeded
                      last edited by 3 Jun 2013, 20:48

                      any thing to worry about with regards to how it will affect my model?

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        thomthom
                        last edited by 3 Jun 2013, 21:27

                        Any crash is potential for data loss if you haven't saved...

                        hm... when I use Selection Toys' Group Copies to Component on a single set it can be undone with no bugsplat. I wonder why this is different...

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

                        1 Reply Last reply Reply Quote 0
                        • F Offline
                          fullyfledgeded
                          last edited by 4 Jun 2013, 20:25

                          I see. Another problem is that, it does not seem to be reducing my file size much at all. If you run your script on the same file http://sketchucation.com/forums/download/file.php?id=106847 you will see size stays the same.

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            thomthom
                            last edited by 5 Jun 2013, 07:34

                            Well, yes - because you're not reducing the number of component definitions. Groups in SketchUp are like ComponentInstances - they have ComponentDefinitions. When you see a Group that has copies in Entity Info it means they all share the same definition.

                            The only difference is that SketchUp makes groups unique when you modify them.

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

                            1 Reply Last reply Reply Quote 0
                            • F Offline
                              fullyfledgeded
                              last edited by 6 Jun 2013, 10:31

                              yes that makes logical sense. Someone once told me that comps' only take up the size of the definition & all instances don't add to count towards memory, where as group instances do.

                              cheers

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                thomthom
                                last edited by 6 Jun 2013, 10:46

                                Well, that is true under the assumption that all group instances are unique. But SketchUp makes some internal optimizations and make copies share the same definition until you edit one of them. Or to be more specific, you don't even need to make changes, just open the group and close it. Then you'll have a new definition - which takes up more space.

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

                                1 Reply Last reply Reply Quote 0
                                • F Offline
                                  fullyfledgeded
                                  last edited by 6 Jun 2013, 14:33

                                  Ah yes that's what i thought it should do, but I told myself otherwise by mishearing something. I Learn't from youtube, I guess once you grasp ruby, you'd have a more in-depth insight into SU.

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    thomthom
                                    last edited by 6 Jun 2013, 14:42

                                    It does give some more insight to some of the technical aspects of SketchUp - why things behave the way they do.

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

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

                                    Advertisement