Last active
October 10, 2015 13:00
-
-
Save jimfoltz/650e65da8a23d2399206 to your computer and use it in GitHub Desktop.
unhide-all.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: unhide-all.rb | |
# author: jim.foltz@gmail.com | |
require 'sketchup.rb' | |
module JF | |
module UnhideAll | |
def self.start | |
model = Sketchup.active_model | |
model.start_operation("Unhide all entities", true) | |
entities = Sketchup.active_model.selection | |
entities = Sketchup.active_model.active_entities if entities.empty? | |
begin | |
unhide(entities) | |
model.layers.each {|l| l.visible = true} | |
rescue => e | |
model.abort_operation | |
puts e | |
else | |
model.commit_operation | |
end | |
end | |
def self.unhide(ent, list = {}) | |
ent.each do |e| | |
case e | |
when Sketchup::Group | |
e.make_unique | |
unhide(e.entities) | |
when Sketchup::ComponentInstance | |
unhide(e.definition.entities, list) unless list.has_key?(e.definition) | |
list[e.definition] = true | |
end | |
e.hidden = false if e.respond_to?(:hidden=) | |
end | |
end | |
menu = defined?(JF.menu) ? JF.menu : UI.menu('Plugins') | |
menu.add_item("Unhide All") { JF::UnhideAll.start } | |
end | |
end # JF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment