[REQ]Explode Groups/Components selected
-
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 powerfullExist Exloder at the Ruby Depot but seems don't work!
So...
-
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 typeTIG.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... -
-
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? -
You are right - I rattled it off too quickly !
Well spotted...
I've adjusted the original code to suit...
Pilou... please re-copy/paste... -
Sure!
Terminatorizer the Return!
Advertisement