Class: Sketchup::DefinitionObserver Abstract

Inherits:
EntityObserver show all
Defined in:
lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb

Overview

This class is abstract.

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.

This observer interface is implemented to react to component definition events.

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



46
47
# File 'lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb', line 46

def onComponentInstanceAdded(definition, instance)
end

#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



71
72
# File 'lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb', line 71

def onComponentInstanceRemoved(definition, instance)
end