Class: Sketchup::LayersObserver

Inherits:
Object
  • Object
show all

Overview

This observer interface is implemented to react to layers events. To implement this observer, create a Ruby class of this type, override the desired methods, and add an instance of the observer to the objects of interests.

Examples:

class MyLayersObserver < Sketchup::LayersObserver
  def onLayerAdded(layers, layer)
    puts "onLayerAdded: #{layer.name}"
  end
end

Sketchup.active_model.layers.add_observer(MyLayersObserver.new)
Sketchup.active_model.layers.add("Hello World")

Version:

  • SketchUp 6.0

Instance Method Summary collapse

Instance Method Details

#onCurrentLayerChanged(layers, layer) ⇒ nil

The #onCurrentLayerChanged method is called when the user selects a different active layer.

Examples:

class MyLayersObserver < Sketchup::LayersObserver
  def onCurrentLayerChanged(layers, layer)
    puts "onCurrentLayerChanged: #{layer.name}"
  end
end

Sketchup.active_model.layers.add_observer(MyLayersObserver.new)
layer = Sketchup.active_model.layers.add("Hello World")
Sketchup.active_model.active_layer = layer

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#onLayerAdded(layers, layer) ⇒ nil

The #onLayerAdded method is called when a new layer is added to a model.

Examples:

class MyLayersObserver < Sketchup::LayersObserver
  def onLayerAdded(layers, layer)
    puts "onLayerAdded: #{layer.name}"
  end
end

Sketchup.active_model.layers.add_observer(MyLayersObserver.new)
Sketchup.active_model.layers.add("Hello World")

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#onLayerChanged(layers, layer) ⇒ nil

The #onLayerChanged method is called when a layer is changed.

Examples:

def onLayerChanged(layers, layer)
  puts "onLayerChanged: #{layer.name}"
end

Sketchup.active_model.layers.add_observer(MyLayersObserver.new)
layer = Sketchup.active_model.layers.add("Hello World")
layer.name = "Hello Universe"

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 2014

#onLayerRemoved(layers, layer) ⇒ nil

The #onLayerRemoved method is called when a layer is removed from a model.

Examples:

class MyLayersObserver < Sketchup::LayersObserver
  def onLayerRemoved(layers, layer)
    puts "onLayerRemoved: #{layer.name}"
  end
end

Sketchup.active_model.layers.add_observer(MyLayersObserver.new)
layer = Sketchup.active_model.layers.add("Hello World")
Sketchup.active_model.layers.remove(layer)

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#onRemoveAllLayers(layers) ⇒ nil

The #onRemoveAllLayers method is called when all layer are removed from a model.

Examples:

class MyLayersObserver < Sketchup::LayersObserver
  def onRemoveAllLayers(layers)
    puts "onRemoveAllLayers: #{layers}"
  end
end

Sketchup.active_model.layers.add_observer(MyLayersObserver.new)
layer = Sketchup.active_model.layers.add("Hello World")
Sketchup.active_model.layers.remove(layer)

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0