Adding InstanceObserver to each instance definition in Ruby

The documentation mentions that the DefinitionObserver and InstanceObserver classes inherit #onChangeEntity from EntityObserver superclass. But since the SU2016 overhaul there are no longer empty callbacks to inherit.

Still this does mean that the SketchUp engine is supposed to call #onChangeEntity callbacks for these observers. So you should try adding this callback when you want to react to changes made to a definition or an instance. (Keep in mind that changes to a definition’s entities collection are notified via EntitiesObserver objects attached to the definition’s entities collection.)


P.S. - Also it is not necessary to create a separate observer instance for every object it is attached to, as often the collection object and the instance object reference are passed into the observer callbacks.

This means that usually a single observer instance per model can be used to watch collections and entities. The references for the various observers on a model can be kept inside the model observer instance object as instance variables.