DefinitionsObserver

SketchUp 6.0+

interface

Parent: Object

Introduction

This observer interface is implemented to react to events on a definitions collection. To implement this observer, create a Ruby class of this type, override the desired methods, and add an instance of the observer to the collection of interest.

     # This is an example of an observer that watches the definitions
     # collection for new components and shows a messagebox.
     class MyDefinitionsObserver < Sketchup::DefinitionsObserver
       def onComponentAdded(definition, definition)
         UI.messagebox("onComponentAdded: " + definition.to_s)
       end
     end

     # Attach the observer
     Sketchup.active_model.definitions.add_observer(MyDefinitionsObserver.new)

Methods

DefinitionsObserver.onComponentAddedSketchUp 6.0+

The onComponentAdded method is called whenever a definition is added to the definitions collection.

Arguments:

definitions
A Component definitions object.
definition
A component definition object.

Returns:

nil
 def onComponentAdded(definitions, definition)
   UI.messagebox("onComponentAdded: " + definition.to_s)
 end

DefinitionsObserver.onComponentPropertiesChangedSketchUp 6.0+

The onComponentPropertiesChanged method is called whenever a definition's name or description are changed.

This does not fire when Glue To, Cuts Opening, or Face Camera settings are changed.

Returns:

nil
 def onComponentPropertiesChanged(definitions, definition)
   UI.messagebox("onComponentPropertiesChanged: " + definition.to_s)
 end

DefinitionsObserver.onComponentRemovedSketchUp 6.0+

The onComponentAdded method is called whenever a definition is removed from the definitions collection. NOTE: This methods fires twice for each Component/Group erased.

Arguments:

definitions
A Component definitions object.
definition
A component definition object.

Returns:

nil
 def onComponentRemoved(definitions, definition)
   UI.messagebox("onComponentRemoved: " + definition.to_s)
 end

DefinitionsObserver.onComponentTypeChangedSketchUp 6.0+

The onComponentTypeChanged event is fired when a component is converted to a group or vice versa. (In the underlying implementation, Groups are just a special kind of definition that is allowed to only have a single instance.)

Arguments:

definitions
A Component definitions object.
definition
A component definition object.

Returns:

nil
 def onComponentTypeChanged(definitions, definition)
   UI.messagebox("onComponentTypeChanged: " + definition.to_s)
 end

  

Trimble Home
About Trimble - Privacy Policy - Contact Us