Class: Sketchup::DefinitionObserver

Inherits:
EntityObserver show all

Overview

This observer interface is implemented to react to component definition 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 definitions of interests.

Examples:

# This is an example of an observer that watches a specific definition
# for new component insertions.
class MyDefObserver < Sketchup::DefinitionObserver
  def onComponentInstanceAdded(definition, instance)
    puts "onComponentInstanceAdded(#{definition}, #{instance})"
  end
end

# Attach the observer
Sketchup.active_model.definitions[0].add_observer(MyDefObserver.new)

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Methods inherited from EntityObserver

#onChangeEntity, #onEraseEntity

Instance Method Details

#onComponentInstanceAdded(definition, instance) ⇒ nil

The #onComponentInstanceAdded method is called when a new component instance is added to a model.

Examples:

def onComponentInstanceAdded(definition, instance)
  puts "onComponentInstanceAdded(#{definition}, #{instance})"
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#onComponentInstanceRemoved(definition, instance) ⇒ nil

Note:

Due to the underlying way that the SketchUp Move Tool is implemented, this method is fired on a Move + Copy operation even though no ComponentInstance is apparently removed.

The #onComponentInstanceRemoved method is called when a component instance is removed from a model.

Examples:

def onComponentInstanceRemoved(definition, instance)
  puts "onComponentInstanceRemoved(#{definition}, #{instance})"
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0