Skip to content

Instantly share code, notes, and snippets.

@jimfoltz
Last active October 10, 2015 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimfoltz/650e65da8a23d2399206 to your computer and use it in GitHub Desktop.
Save jimfoltz/650e65da8a23d2399206 to your computer and use it in GitHub Desktop.
unhide-all.rb
# 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