Add Layer Color change to LayersObserver

bug
entityobserver

#1

I’ve run some tests to see if the LayersObserver#onLayerChanged method will run if a Layer Color is changed, but the observer only seems to trigger if the layer’s visibility changes. Would it be possible for the LayersObserver to trigger if a layer’s color is altered by the user?

I ran my tests in SketchUp 2016, so I don’t know if this works in 2017.

Or, if there’s another way of determining if a layer’s color has changed, I’m open to suggestions.

Thanks!


#2

I tried an EntityObserver#onChangeEntity callback
(because a Layer is a subclass of Entity, so it is one.)

But it does NOT fire on a manual color change via the Layer Manager panel.

But it DOES fire via a coding color change, ie:

Sketchup.active_model.layers[1].color= "Red"

Visibility changes also fire the onChangeEntity callback both maunal and code.

(SU2016)


#3

Thanks Dan. Unfortunately I’m looking to determine when a color is changed manually by the user. I guess at this time there is no way to do this. What do you think is the likelihood of this being included in one of the observers at some point?


#4

Well it is a bug in the core.

The color change should fire the EntityObserver#onChangeEntity callback for both situations.

The likely reason it fell through the cracks, is that layer color change was not always exposed to the API. When it was added with SketchUp 2014, the manual UI part of the equation was overlooked.