How to change color of several layers at once

Well … try this. You can adjust the Gray RGB components to suit.

Example_SetAllLayersGray.rb (878 Bytes)

module Example
  module SetAllLayersGray

    extend self

    @@loaded = false unless defined?(@@loaded)

    def gray_all_layers
      shade = Sketchup::Color.new(77,77,77)
      layers = Sketchup.active_model.layers.to_a
      choice = UI.messagebox('Set "Layer0" black?',MB_YESNO)
      if choice == IDYES
        zero = layers.delete(Sketchup.active_model.layers["Layer0"])
        zero.color= "Black" if !zero.nil?
      end
      layers.each do |layer|
        layer.color= shade
      end
    end

    def gray_all_layers_command
      choice = UI.messagebox('Set all layer colors to gray?',MB_YESNO)
      gray_all_layers() if choice == IDYES
    end

    unless @@loaded
      UI.menu('Plugins').add_item('Set All Layers Gray') {
        gray_all_layers_command()
      }
      @@loaded = true
    end

  end
end
3 Likes