[ruby doc] entity observers and observers in general
-
class MyEntityObserver < Sketchup;;EntityObserver def onEntityChanged (entity) p entity # do something end end def observe_ent() ent=Sketchup.active_model.selection.first ent.add_observer MyEntityObserver.new end
For the life of me, I can't seem to get 'onEntityChanged' to get called. Is this a bug or what? The documentation for all of the observer classes is pathetic. I would like every class of observer to have a detailed description of what has to happen for their methods to be called. In this example, what change must be made to the entity for the 'onEntityChanged' method to get called? If I ever figure it out, I'll let you know.
Thanks for working on this Todd!
@unknownuser said:
# In your code. If the face changes, MyEntityObserver is called. > > face.add_observer(MyEntityObserver.new) >
-
Hi Whaat,
Have a look here:
http://www.sketchucation.com/forums/scf/viewtopic.php?f=57&t=3282&p=16071&hilit=observer#p16071 -
I agree Whaat. But, please come back with a solution to the problem, then I'll update the doc. (Other's can provide the solution too, of course)
Todd
-
It seems like the problem is that the name of the method is wrong in the API docs. It should be 'onChangeEntity' not 'onEntityChanged'.
This should be updated in the docs.
EDIT: on closer inspection, the method is only wrong in the example at the top of the page. The correct method is shown on the page near the bottom. (It is confusing though)
-
OK. I have fixed the "example" (if you could call it that) at the top of the EntityObserver file. I think I have an example somewhere I might could clean up and add to it.
The same "bad example" is in other observer files too. I'll get to those as topics come up for inclusion.
What's really needed for the observers, and I can start on it, is some "big picture" concept information.
Thanks!
Advertisement