Class: Sketchup::EntitiesObserver Abstract

Inherits:
Object
  • Object
show all

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 objects of interests.

This observer interface is implemented to react to Entities collection events.

Examples:

# This is an example of an observer that watches the entities collection
# new added elements and writes a message on the console.
class MyEntitiesObserver < Sketchup::EntitiesObserver
  def onElementAdded(entities, entity)
    puts "onElementAdded: #{entity}"
  end
end

# Attach the observer
Sketchup.active_model.entities.add_observer(MyEntitiesObserver.new)

Version:

  • SketchUp 6.0

Direct Known Subclasses

PagesObserver

Instance Method Summary # collapse

Instance Method Details

#onActiveSectionPlaneChanged(entities) ⇒ nil

The #onActiveSectionPlaneChanged method is invoked when a section plane within this entities is activated or the active one is deactivated.

Examples:

def onActiveSectionPlaneChanged(entities)
  sp = entities.active_section_plane
  if sp.nil?
    puts "Section plane is deactivated on #{entities}"
  else
    puts "#{sp} is activated on #{entities}"
  end
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 2014

#onElementAdded(entities, entity) ⇒ nil

The onElementAdded method is invoked when a single element is added to the Sketchup::Entities collection.

Examples:

def onElementAdded(entities, entity)
  puts "onElementAdded: #{entity}"
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#onElementModified(entities, entity) ⇒ nil

The #onElementModified method is invoked whenever one or more elements in the collection are modified.

Examples:

def onElementModified(entities, entity)
  puts "onElementModified: #{entity}"
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 8.0

#onElementRemoved(entities, entity_id) ⇒ nil

The #onElementRemoved method is invoked when a single element is removed from the Sketchup::Entities collection. Note that the entity has been deleted and should not be used in anyway except to know that the entity has been deleted.

Examples:

def onElementRemoved(entities, entity_id)
  puts "onElementRemoved: #{entity_id}"
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#onEraseEntities(entities) ⇒ nil

The #onEraseEntities method is invoked when one or more entities are erased.

Examples:

def onEraseEntities(entities)
  puts "onEraseEntities: #{entities}"
end

Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0