123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::MaterialsObserver Abstract

Relationships
Inherits: Object

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.

Note:

The callback onMaterialRemoveAll has been deprecated, we recommend using #onMaterialRemove instead.

This observer interface is implemented to react to materials events.

Examples:

class MyMaterialsObserver < Sketchup::MaterialsObserver
  def onMaterialAdd(materials, material)
    puts "onMaterialAdd: #{material}"
  end
end

Sketchup.active_model.materials.add_observer(MyMaterialsObserver.new)

Version:

  • SketchUp 6.0

Instance Method Summary

Instance Method Details

#onMaterialAdd(materials, material) ⇒ nil

The #onMaterialAdd method is invoked whenever a new material is added.

Examples:

def onMaterialAdd(materials, material)
  puts "onMaterialAdd: #{material}"
end

Parameters:

Version:

  • SketchUp 6.0

#onMaterialChange(materials, material) ⇒ nil

The #onMaterialChange method is invoked whenever a material’s texture image is altered.

Examples:

def onMaterialChange(materials, material)
  puts "onMaterialChange: #{material}"
end

Parameters:

Version:

  • SketchUp 6.0

#onMaterialRefChange(materials, material) ⇒ nil

The #onMaterialRefChange method is invoked whenever the number of entities that a material is painted on changes. This could be due to the user manually painting something, but it could also be when faces are split, pasted, push-pulled, deleted, etc.

Examples:

def onMaterialRefChange(materials, material)
  puts "onMaterialRefChange: #{material}"
end

Parameters:

Version:

  • SketchUp 6.0

#onMaterialRemove(materials, material) ⇒ nil

The #onMaterialRemove method is invoked whenever a material is deleted.

Examples:

def onMaterialRemove(materials, material)
  puts "onMaterialRemove: #{material}"
end

Parameters:

Version:

  • SketchUp 6.0

#onMaterialSetCurrent(materials, material) ⇒ nil

The #onMaterialSetCurrent method is invoked whenever a different material is selected in the Materials dialog.

The materials parameter might be Nil when the material is picked from the materials libraries and not yet added to the model.

Examples:

def onMaterialSetCurrent(materials, material)
  puts "onMaterialSetCurrent: #{material}"
end

Parameters:

Version:

  • SketchUp 6.0

#onMaterialUndoRedo(materials, material) ⇒ nil

Note:

Due to a bug, this callback does not fire in SU6 or SU7. You can use the ModelObserver#onTransactionStart to capture all undo events.

The #onMaterialUndoRedo method is invoked whenever a material is altered and then those changes are undone or redone.

Examples:

def onMaterialUndoRedo(materials, material)
  puts "onMaterialUndoRedo: #{material}"
end

Parameters:

Version:

  • SketchUp 6.0