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

[REQ]Explode Groups/Components selected

Scheduled Pinned Locked Moved Plugins
6 Posts 3 Posters 2.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.
  • P Offline
    pilou
    last edited by 31 Mar 2012, 02:25

    Wanted explode on all levels Groups & Components selected

    Exist a total explosion of all groups components (selected or not) of the Model by Rick Wilson at Smustard
    Too powerfull πŸ˜„

    Exist Exloder at the Ruby Depot but seems don't work! 😞

    So...

    Frenchy Pilou
    Is beautiful that please without concept!
    My Little site :)

    1 Reply Last reply Reply Quote 0
    • T Online
      TIG Moderator
      last edited by 31 Mar 2012, 14:54

      This code Explodes all Selected Groups/Instances [including all nested Groups/Instances inside these, down through all levels of nesting...]
      Usage: in the Ruby Console type TIG.exploderizer + <enter>
      Paste the code into a file called "TIG-exploderizer.rb" in the Plugins folder and restart Sketchup.

      require 'sketchup.rb'
      module TIG
          def TIG.exploderizer()
              model=Sketchup.active_model
              ss=model.selection
              return nil unless ss[0]
              toex=ss.to_a.find_all{|e|e.class==Sketchup;;Group or e.class==Sketchup;;ComponentInstance}
              more=true
              done=[]
              while more
                len=toex.length
                toex.clone.each{|e|
                  next if done.include?(e)
                  tarr=[]
                  tarr=e.entities.to_a if e.class==Sketchup;;Group
                  tarr=e.definition.entities.to_a if e.class==Sketchup;;ComponentInstance
                  tarr.each{|ee|
                    toex << ee if ee.class==Sketchup;;Group or ee.class==Sketchup;;ComponentInstance
                  }
                  done << e
                  done.uniq!
                }
                toex.uniq!
                more=false if toex.length==len
              end
              model.start_operation("TIG.exploderizer")
                toex.uniq.reverse.each{|e|e.explode if e.valid?}
                puts "Exploded #{toex.length} Groups/Instances."
              model.commit_operation
          end
      end
      

      Note: it will Explode any inner Groups/Instances inside a Component Definition even if it is outside of the Selection, if there is an Instance of it in the Selection.
      EDIT: fixed glitch with component entities...

      TIG

      1 Reply Last reply Reply Quote 0
      • P Offline
        pilou
        last edited by 31 Mar 2012, 15:26

        Bravo! 😎
        Works like a charm! πŸ‘

        TIG The Terminatorizer! 😎

        termi.jpg

        Frenchy Pilou
        Is beautiful that please without concept!
        My Little site :)

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdmitch
          last edited by 31 Mar 2012, 15:46

          Isn't
          tarr=e.entities.to_a if e.class==Sketchup::Group or e.class==Sketchup::ComponentInstance
          only true for groups? Wouldn't it need to be e.definition.entities for components?

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • T Online
            TIG Moderator
            last edited by 31 Mar 2012, 16:03

            You are right - I rattled it off too quickly !
            Well spotted... β˜€
            I've adjusted the original code to suit...
            Pilou... please re-copy/paste...

            TIG

            1 Reply Last reply Reply Quote 0
            • P Offline
              pilou
              last edited by 31 Mar 2012, 16:53

              Sure!
              Terminatorizer the Return! πŸ˜‰

              Frenchy Pilou
              Is beautiful that please without concept!
              My Little site :)

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

              Advertisement