123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::DefinitionObserver Abstract

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Sketchup::EntityObserver

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

EntityObserver - Inherited

#onChangeEntity

The #onChangeEntity method is invoked when your entity is modified.

#onEraseEntity

The #onEraseEntity method is invoked when your entity is erased.

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:

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:

Version:

  • SketchUp 6.0