• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

[ruby doc] entity observers and observers in general

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 3 Posters 752 Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    Whaat
    last edited by 3 Feb 2008, 23:29

    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)             
    >    
    

    SketchUp Plugins for Professionals

    1 Reply Last reply Reply Quote 0
    • D Offline
      Didier Bur
      last edited by 3 Feb 2008, 23:44

      Hi Whaat,
      Have a look here:
      http://www.sketchucation.com/forums/scf/viewtopic.php?f=57&t=3282&p=16071&hilit=observer#p16071

      DB

      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by 4 Feb 2008, 00:08

        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

        1 Reply Last reply Reply Quote 0
        • W Offline
          Whaat
          last edited by 4 Feb 2008, 18:34

          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)

          SketchUp Plugins for Professionals

          1 Reply Last reply Reply Quote 0
          • T Offline
            todd burch
            last edited by 4 Feb 2008, 19:58

            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!

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              5/5
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement